MERA.jl API Reference

MERA.jl's comprehensive API for high-performance astrophysical data analysis and computational workflows

Types

Abstract type hierarchies

DataSetType hierarchy

  • HydroMapsType <: DataMapsType
  • PartMapsType <: DataMapsType

List of types

Functions

Macros

Mera.@applyMacro

Find examples in the Mera Documentation for: filter data with pipeline macros

Mera.@filterMacro
@filter(obj, :column op value)

Filter by a single comparison. If obj is a Mera data object (hydro/gravity/RT/particles/ clumps) it routes through filterdata: the column may be any getvar quantity (derived physics, code units) and the result is a new object of the same type. If obj is a raw IndexedTable, the classic per-row column filter is used. For units, compound conditions (&/|/!) and percentile/finite selectors, use filterdata with Above etc.

hot = @filter gas :rho >= 1e2     # Mera object → HydroDataType of the matching cells
sub = @filter gas.data :rho >= 1e2  # raw table → filtered table (classic behaviour)
Mera.@whereMacro

Find examples in the Mera Documentation for: filter data with pipeline macros

Documentation Types

Mera.AMRMapsTypeType

Mutable Struct: Contains the maps/units returned by an AMR cell-based projection (hydro, gravity-with-hydro, and radiative-transfer all return this type; the provenance is preserved in the .info field). smallr/smallc are hydro-only and set to 0 for RT.

Fields

  • maps::SortedDict{Symbol,Array{Float64,2}} — one 2D map per requested quantity, keyed by variable symbol (e.g. :sd, :rho, :vx, :T). For an intensive variable the map is the weighted average per pixel; for an extensive variable (:sd, and :mass/:ekin/:etherm/ :volume under mode=:sum) it is the per-pixel column/sum. Access as proj.maps[:sd].
  • maps_unit::SortedDict{Symbol,Symbol} — the physical unit of each map (e.g. :Msol_pc2, :g_cm3, :km_s, :standard for code units), keyed by the same symbols as maps.
  • maps_lmax::SortedDict — per-map record of the AMR level a map was projected onto (relevant when a coarser lmax than the simulation maximum was requested).
  • maps_weight::SortedDict{Symbol,Symbol} — the weighting used per map: :mass, :volume, or :nothing for the extensive :sum/:sd accumulations that carry no weighting.
  • maps_mode::SortedDict{Symbol,Symbol} — how each map was reduced: :mass_weighted, :volume_weighted, :standard, or :sum.
  • lmax_projected::Real — the maximum AMR level actually used in the projection.
  • lmin::Int, lmax::Int — the simulation's level range carried over for provenance.
  • ranges::Array{Float64,1} — the 6-element projected sub-box [xmin,xmax,ymin,ymax,zmin,zmax] in box-fraction units [0,1]. (proj.xrange/yrange/zrange are accessor slices of this.)
  • extent::Array{Float64,1}[xmin,xmax,ymin,ymax] of the map in code length units (multiply by proj.scale.kpc etc. for physical axes); the data-plane extent for plotting.
  • cextent::Array{Float64,1} — the same extent but centred on the chosen projection centre (so the centre sits at 0); use for axes labelled relative to the centre.
  • ratio::Float64 — pixel aspect ratio of the map (xspan/yspan).
  • effres::Int — the effective square resolution (pixels per side); proj.res aliases this.
  • pixsize::Float64 — physical size of one pixel in code length units (× scale for kpc/pc).
  • boxlen::Float64 — the simulation box length in code units.
  • smallr::Float64, smallc::Float64 — hydro density/sound-speed floors (0 for RT projections).
  • scale::ScalesType003 — unit-conversion factors (code↔physical) inherited from the dataset.
  • info::InfoType — the full simulation descriptor (provenance: output, paths, cosmology, …).
  • los, up, cam_right, center::Vector{Float64} — off-axis camera basis and centre; empty Float64[] for axis-aligned projections. proj.direction returns :offaxis when populated.
Mera.AboveType
Above(quantity, value; unit=:standard)

Keep rows where getvar(obj, quantity, unit) > value.

Mera.AbovePercentileType
AbovePercentile(quantity, p; unit=:standard)
BelowPercentile(quantity, p; unit=:standard)

Keep rows above (below) the p-th percentile of quantity over obj (p ∈ [0,100]) — an adaptive threshold, e.g. the densest 10 % of cells: AbovePercentile(:rho, 90).

Mera.AbstractRegionType
AbstractRegion

Supertype of the composable region value types passed to subregion: Cuboid, Sphere, Cylinder, SphericalShell. A region is a geometry-relative-to-center value type; subregion(obj, region) selects the cells it covers and, with split=true, attaches the exact per-cell inside-fraction. Regions compose with the boolean operators (intersection), (union), \ (difference) and ! (complement) — e.g. Sphere(20) \ Cylinder(5, 30) drills a cylindrical hole through a ball.

Mera.ArgumentsTypeType

Mutable Struct: Contains fields to use as arguments in functions

Mera.BelowType
Below(quantity, value; unit=:standard)

Keep rows where getvar(obj, quantity, unit) < value.

Mera.BelowPercentileType
BelowPercentile(quantity, p; unit=:standard)

Keep rows below the p-th percentile of quantity over obj (p ∈ [0,100]); the lower counterpart of AbovePercentile.

Mera.BoundType
Bound(egrav=:tree; iterative=true, softening=0.0, direct_max=2000)

Self-boundedness validator: builds the per-clump energy budget with potential egrav (:tree Barnes–Hut / :direct exact / :approx 3·GM²/5R), optionally strips unbound members (iterative, SUBFIND), and keeps only self-bound clumps (e_kin+e_therm[+e_mag] < |e_grav|).

Mera.CheckOutputNumberTypeType

Mutable Struct: Contains the existing simulation snapshots in a folder and a list of the empty output-folders

Mera.ClumpCardType
ClumpCard(kind, field=:rho; threshold, linking_length, threshold_unit=:standard, pos_unit=:kpc, mass_unit=:Msol, min_members=1, label="")

A report card that runs clumpfind and reports the clump count + total clump mass (the full ClumpCatalog is kept in the result card's data.catalog).

Mera.ClumpCatalogType
ClumpCatalog

Result of clumpfind. clumps is a vector of per-clump NamedTuples (sorted most-massive first); meta records the search parameters; tree is the StructureTree hierarchy (only when built via hierarchy=true, else nothing). Index/iterate it like a vector (cat[1], length(cat), for c in cat).

Mera.ClumpDataTypeType

Mutable Struct: Contains clump data and information about the selected simulation

ClumpDataType <: ContainMassDataSetType

Mera.CombinedCardMethod
CombinedCard(datatypes, compute; unit=:fraction, label="combined")
CombinedCard(datatypes; unit=:fraction, label="combined") do datas … end

A cross-datatype scalar card. compute(datas) receives a Dict{Symbol,Any} of the read data objects for datatypes and returns a number. Computed only if all datatypes are present. See the built-ins baryon_fraction and clump_mass_fraction.

Mera.ContainMassDataSetTypeType

Abstract Supertype of all datasets that contain mass variables

HydroPartType <: ContainMassDataSetType <: DataSetType

Mera.CoveringGridResultType
CoveringGridResult

Result of covering_grid / slice. grid maps each variable to its uniform array (3-D for a covering grid, 2-D for a slice); level is the uniform refinement level, dims the array size, extent the physical bounds [x0,x1,y0,y1,z0,z1] and cellsize the physical cell size (both in pos_unit). Index grid[:rho] for the array.

Mera.CuboidType
Cuboid(; xrange, yrange, zrange, center=[:bc], range_unit=:kpc)

An axis-aligned box; xrange/yrange/zrange are [lo, hi] offsets from center (in range_unit), as in subregion(:cuboid).

Mera.CustomType
Custom(f)

Keep clumps for which f(clump)::Bool is true (clump is the per-clump NamedTuple, with fields n_members, mass, com, peak, radius and — when bound — e_kin, e_grav, alpha_vir, bound).

Mera.CylinderType
Cylinder(radius, height; axis=[0,0,1], center=[:bc], range_unit=:kpc)

A cylinder of cylindrical radius spanning ±height along axis (so height is the half-height, matching the existing subregion(:cylinder) convention). axis is the symmetry direction (any non-zero 3-vector, normalised internally) — e.g. a galaxy's spin vector for a tilted disk; the default [0,0,1] is the classic z-aligned cylinder.

Mera.CylindricalShellType
CylindricalShell(r_in, r_out, height; axis=[0,0,1], center=[:bc], range_unit=:kpc)

A cylindrical shell r_in ≤ r_cyl ≤ r_out of half-height height along axis (the value-type analogue of shellregion(:cylinder); axis allows a tilted shell).

Mera.DataMapsTypeType

Abstract Supertype of all the different dataset type maps AMRMapsType <: DataMapsType PartMapsType <: DataMapsType

Mera.DataSetTypeType

Abstract Supertype of all the different dataset types

HydroPartType <: ContainMassDataSetType <: DataSetType

Mera.DendrogramType
Dendrogram(field=:rho; threshold, linking_length, threshold_unit=:standard, min_delta=0.0, backend=CellLinkedList)

Multi-scale hierarchy finder (Rosolowsky & Leroy 2008): the finest density peaks (local maxima with prominence ≥ min_delta) are the catalog's leaf clumps, and clumpfind(obj, …; hierarchy=true) attaches the full merge StructureTree recording the level at which they join. min_delta (in field units) is the minimum peak-to-saddle contrast for a separate leaf.

Mera.DensityWatershedType
DensityWatershed(field=:rho; threshold, linking_length, threshold_unit=:standard, peak_min_distance=2·linking_length, persistence=0.0, backend=CellLinkedList)

Watershed finder: friends-of-friends for connectivity, then each connected group is split into density-descending basins (peaks separated by peak_min_distance), so touching cores are resolved along their saddles (DENMAX/SUBFIND-style). persistence (in field units) prunes shallow basins: a basin whose prominence — peak value minus the saddle at which it joins a deeper basin — is below persistence is merged into that deeper basin (topological contrast control, Rosolowsky & Leroy 2008 min_delta). persistence=0 keeps every local maximum (bare watershed).

Mera.DescriptorTypeType

Mutable Struct: Contains the collected information about the descriptors

Mera.EqualsType
Equals(quantity, value; unit=:standard, atol=0.0)

Keep rows where getvar(obj, quantity, unit) == value (within atol). Best for discrete fields such as :level, particle ids or :family.

Mera.FluxBudgetTypeType
FluxBudgetType

Result of fluxbudget. rates is a NamedTuple keyed by quantity (:mass, :momentum, :energy, :metals), each an (in, out, net, err_in, err_out, err_net, n_in, n_out, unit) NamedTuple (in ≤ 0 inflow, out ≥ 0 outflow, net = in + out; err_* is the sampling/shot-noise standard error of the cell-sum — large when a few cells dominate). components is nothing or a per-phase NamedTuple. surface/radius/shell_width/center record the definition; n_cells the shell cell count; shell_mass_Msol and residual the conservation check.

Mera.FluxMapTypeType
FluxMapType

Result of fluxmap. map is the 2-D surface map of quantity (:vr — mass-weighted mean normal velocity [km/s], inflow < 0 / outflow > 0; or :mdot — the per-bin mass-flux contribution [Msol/yr], whose sum is the net flux total). xedges/yedges are the surface-coordinate bin edges (xlabel/ylabel name them); mass is the Σ-mass map.

Mera.GalaxyFrameType
GalaxyFrame

Orientation + centre returned by face_on / edge_on. Splat the fields straight into projection:

fr = face_on(gas)
projection(gas, :sd; los=fr.los, up=fr.up, center=fr.center, range_unit=fr.center_unit)

Fields: center (in center_unit), los (unit vector the camera looks along), up (unit vector for the camera's up direction), angmom (the net angular-momentum vector the frame was derived from), and info (the source snapshot — so provenance(frame) works).

Mera.GraphSegFinderType
GraphSegFinder(field=:rho; threshold, linking_length, threshold_unit=:standard, scale=1.0, backend=CellLinkedList)

Graph-segmentation finder (Felzenszwalb & Huttenlocher 2004): segments the neighbour graph so that the density variation within a region stays below the contrast between regions. scale k sets the granularity (larger ⇒ fewer, larger segments). Near-linear; good as a fast multi-scale deblender, e.g. deblend=GraphSegFinder(...).

Mera.GridInfoTypeType

Mutable Struct: Contains the collected information about grid

Mera.HDBSCANFinderType
HDBSCANFinder(field=:rho; threshold, linking_length, threshold_unit=:standard, min_cluster_size=5, min_samples=min_cluster_size, backend=CellLinkedList)

Density-adaptive finder — a self-contained HDBSCAN* (Campello+2013; McInnes+2017): core distances from the min_samples-nearest neighbours define a mutual-reachability metric whose minimum spanning tree is condensed into a cluster hierarchy, and the most stable clusters (each with ≥ min_cluster_size members) are extracted. Finds clumps across a wide density range with almost no tuning; points not in any stable cluster are labelled noise (dropped). linking_length only bounds the neighbour search (set it generously).

Mera.Histogram2DMapTypeType

Mutable Struct: Contains the 2D histogram returned by the function: histogram2 and information about the selected simulation

Mera.HydroDataTypeType

Mutable Struct: Contains hydro data and information about the selected simulation

HydroDataType <: HydroPartType

Mera.HydroMapsTypeType
const HydroMapsType = AMRMapsType

Deprecated alias for AMRMapsType (renamed because gravity and RT projections return the same AMR-map type, not only hydro). Kept for backward compatibility: existing code using HydroMapsType (construction, isa, dispatch) keeps working unchanged. Prefer AMRMapsType in new code.

Mera.HydroPartTypeType

Abstract Supertype of data-sets that contain hydro and particle data

HydroPartType <: ContainMassDataSetType <: DataSetType

Mera.IOBenchmarkType
IOBenchmark

Result of run_benchmark: the iops, throughput and openclose sub-results (each with .samples/.stats), the number of runs, the threads levels tested, and total_elapsed seconds. Pass it to plot_results for a figure.

Mera.InRangeType
InRange(quantity, lo, hi; unit=:standard)

Keep rows where lo ≤ getvar(obj, quantity, unit) ≤ hi.

Mera.InfoTypeType

Mutable Struct: Collected information about the selected simulation output

Mera.IsFiniteType
IsFinite(quantity; unit=:standard)

Keep rows where getvar(obj, quantity, unit) is finite (drops NaN/Inf) — data hygiene, e.g. before a statistic. Combine with ! to select the non-finite rows instead.

Mera.LosCubeTypeType

Mutable Struct: an off-axis line-of-sight cube returned by los_cube / velocity_cube.

cube[i,j,k] is the deposited weight (default mass) at sky pixel (i,j) in bin k of the binned line-of-sight quantity (e.g. :vlos, :T, :rho, or a vector (:bx,:by,:bz)). x/y/bins are bin EDGES. Convenience aliases: .velocitybins, .v_unitbin_unit, .direction:offaxis. Store with savecube / load with loadcube.

Fields

  • cube::Array{Float64,3} — the (nx, ny, nbins) data cube: deposited weight per sky pixel and line-of-sight bin. Summing over the 3rd axis recovers the column (moment-0) map.
  • x::Vector{Float64}, y::Vector{Float64} — sky-pixel bin edges in code length units (length nx+1, ny+1); × scale.kpc etc. for physical axes.
  • bins::Vector{Float64} — the line-of-sight quantity bin edges (length nbins+1) in bin_unit (e.g. velocity channels for :vlos).
  • quantity::Any — the binned LOS quantity: a Symbol (:vlos, :T, :rho, …) or a 3-tuple/ vector of symbols for a vector LOS component (e.g. (:bx,:by,:bz)).
  • bin_unit::Symbol — unit of the bins axis (e.g. :km_s, :standard). Alias: .v_unit.
  • weight::Symbol — the deposit weight (:mass or :volume).
  • los, up, cam_right::Vector{Float64} — the orthonormal off-axis camera basis (line of sight, up vector, right vector).
  • center::Vector{Float64} — the projection centre in code units.
  • pixsize::Float64 — physical size of one sky pixel in code length units.
  • boxlen::Float64 — the simulation box length in code units.
  • range_unit::Symbol — the unit the spatial ranges were specified in.
  • scale::ScalesType003 — unit-conversion factors (code↔physical).
  • info::InfoType — the full simulation descriptor (provenance).
Mera.MassAboveType
MassAbove(m)

Keep clumps with mass > m (in the catalog's mass_unit).

Mera.MeraMovieType
MeraMovie

A stack of projected frames over a simulation's outputs, returned by getmovie: frames (a vector of 2D maps), the per-frame outputs and times, the map extent, and the quantity/unit/time_unit. Write it to an animated GIF with savemovie.

Mera.MinMembersType
MinMembers(n)

Keep only clumps with at least n members.

Mera.MortonGridType
MortonGrid <: AbstractNeighborIndex

Neighbour-search backend (pass as backend=MortonGrid to any finder). Like CellLinkedList, but the indexed points are visited in Morton (Z-order) order so spatially-near points are also near in the traversal — neighbour lookups then touch cache-resident coordinates and the access pattern is near-sequential (the locality an out-of-core path also needs). Produces exactly the same neighbour pairs as the CellLinkedList/HashGrid backends; only the traversal order, and hence speed on large selections, differs.

Mera.PartDataTypeType

Mutable Struct: Contains particle data and information about the selected simulation

PartDataType <: HydroPartType

Mera.PartInfoTypeType

Mutable Struct: Contains the collected information about particles

Mera.PartMapsTypeType

Mutable Struct: Contains the maps/units returned by a particle projection (projection(::PartDataType, …)). Particle maps are histogram deposits of the selected quantity onto the sky grid; provenance is preserved in the .info field.

Fields

  • maps::SortedDict{Symbol,Array{Float64,2}} — one 2D map per requested quantity, keyed by variable symbol (e.g. :sd surface density, :vx, :age). :sd is the column mass per pixel area; intensive variables are mass- or volume-weighted averages per pixel.
  • maps_unit::SortedDict{Symbol,Symbol} — the physical unit of each map (e.g. :Msol_pc2, :km_s, :standard for code units), keyed by the same symbols as maps.
  • maps_lmax::SortedDict — per-map record of the grid level the deposit used.
  • maps_mode::SortedDict{Symbol,Symbol} — how each map was reduced: :mass_weighted or :volume_weighted (particle projection has no mode=:sum path; weighting selects between :mass and :volume).
  • lmax_projected::Real — the maximum grid level used.
  • lmin::Int, lmax::Int — the simulation's level range carried over for provenance.
  • ref_time::Real — the reference time (code units) used to convert birth times to ages for age-dependent quantities (e.g. :age); taken from info.time unless overridden.
  • ranges::Array{Float64,1} — the 6-element projected sub-box [xmin,…,zmax] in box-fraction units [0,1]. (proj.xrange/yrange/zrange are accessor slices.)
  • extent::Array{Float64,1}[xmin,xmax,ymin,ymax] of the map in code length units (× proj.scale.kpc etc. for physical axes).
  • cextent::Array{Float64,1} — the same extent centred on the projection centre.
  • ratio::Float64 — pixel aspect ratio of the map (xspan/yspan).
  • effres::Int — effective square resolution (pixels per side); proj.res aliases this.
  • pixsize::Float64 — physical size of one pixel in code length units (× scale for kpc/pc).
  • boxlen::Float64 — the simulation box length in code units.
  • scale::ScalesType003 — unit-conversion factors (code↔physical) inherited from the dataset.
  • info::InfoType — the full simulation descriptor (provenance).
  • los, up, cam_right, center::Vector{Float64} — off-axis camera basis and centre; empty Float64[] for axis-aligned projections. proj.direction returns :offaxis when populated.
Mera.PersistenceFinderType
PersistenceFinder(field=:rho; threshold, linking_length, persistence, threshold_unit=:standard, backend=CellLinkedList)

Topological persistence clustering (0-dim persistent homology / ToMATo; Chazal+2013): a superlevel-set filtration of the density field where a peak is kept as a separate cluster only if its prominence (peak − merge saddle) reaches persistence. Principled, parameter-light deblending that is robust in crowded fields.

Mera.PhaseCardMethod
PhaseCard(kind, xvar, yvar; weight=:mass, nbins=(80,80), xscale=:log, yscale=:log, xunit=:standard, yunit=:standard, label="")

A phase (2-D histogram) card for a ReportPlan.

Mera.PhaseSpaceFoFType
PhaseSpaceFoF(field=:rho; threshold, linking_length_pos, linking_length_vel, threshold_unit=:standard, backend=CellLinkedList)

6-D phase-space friends-of-friends (Rockstar-style; Behroozi+2013): points link only when within linking_length_pos in space and linking_length_vel (km/s) in velocity, so kinematically distinct populations that overlap spatially — streams, subhaloes, tidal debris — separate. Needs velocities (the finder loads them automatically).

Mera.ProfileCardType
ProfileCard(kind, xvar, yvar=nothing; weight=:mass, nbins=40, geometry=:none, unit=:standard, xunit=:standard, range_unit=:standard, center=[:bc], yscale=:auto, label="")

A profile (1-D radial/other profile) card for a ReportPlan. For a disk galaxy use xvar=:r_cylinder, geometry=:cylindrical (radius in the disk plane); :r_sphere, geometry=:spherical suits a halo/spheroid. yscale sets the y-axis when plotted: :log/:log10 (log₁₀), :identity (linear), or :auto (log when the profile is positive and spans ≳ 1.5 decades, e.g. density).

Mera.ProjectionCardMethod
ProjectionCard(kind, var; unit=:standard, weight=:mass, res=256, direction=:z, center=[:bc], range_unit=:standard, label="")

A projection card (surface-density / mass-weighted map) for a ReportPlan.

Mera.ProvenanceType
Provenance

Reproducibility record returned by provenance: mera_version, simulation path, output, simcode, cosmological, the snapshot time_myr (physical time in Myr; the age of the universe for a cosmological run), redshift and aexp, boxlen, ndim, levelmin/levelmax, the serialized scale_type (e.g. :ScalesType003), and the output's file_ctime. Render a one-liner with provenance_string.

Mera.QuickLookResultType
QuickLookResult

Result of quicklook. Fields: info, levelmin, levelmax, lmax_used (level actually read, nothing for a header-only call), ncells (cells read), sampled (true ⇒ coarse/partial ⇒ estimates are approximate), maps (a NamedTuple of surface-density projections: gas x, y, z, face-on stars/dm when particles are present, plus a face-on magnetic-field map bmag (μG) on an MHD run, or nothing), phase (the ρ–T histogram, or nothing), budget (a NamedTuple global snapshot budget — gas/stellar/DM mass and current SFR — or nothing), and summary (a NamedTuple of facts + estimates).

Mera.QuickReportType
QuickReport

The result of report: cards (a vector of [ReportResultCard]), summary (header facts), provenance, cost (timings), and info. Render with render(report, :ascii|:jld2|:file) or reload with loadreport.

Mera.ReportPlanType
ReportPlan(output; path=".", cards=[], lmax=-1, budget=2_000_000)

A declarative, inspectable plan of report cards. Build it, preview its cost, then run it with report. cards is a vector of ReportCard. lmax=-1 picks a budgeted level (coarse if the full output exceeds budget cells), mirroring quicklook.

Mera.ReportResultCardType
ReportResultCard

A computed card inside a [QuickReport]: label, kind (:map/:phase/:profile/:scalar), datatype, func, the plain-data data payload, and a meta NamedTuple (units, ranges, cost_s, sampled, …).

Mera.SFRCardType
SFRCard(kind=:particles; tbinsize=10.0, trange=[0.0,missing], unit=:Msol_yr, mode=:none, mass=:auto, mask=nothing, label="")

A star-formation-history card (sfr). mode=:probability gives the normalised SFH (a fraction); mass=:auto prefers a stored initial-mass field; mask=obj->BitVector subselects.

Mera.SatisfiesType
Satisfies(quantity, f; unit=:standard)

Keep rows where f(value)::Bool for each getvar(obj, quantity, unit) value — a composable arbitrary predicate (the value-type form of the filterdata(obj, :q, pred) shorthand).

Mera.ScalarCardMethod
ScalarCard(kind, var; reduce=:sum, unit=:standard, fraction=false, relative_to=nothing, mask=nothing, label="")

A scalar reduction card (reduce ∈ :sum,:mean,:extrema,:count). fraction=true divides by the total of relative_to (or var); mask=obj->BitVector restricts the rows.

Mera.ScalesType002Type

Mutable Struct: Contains the created scale factors from code to physical units

Mera.SphereType
Sphere(radius; center=[:bc], range_unit=:kpc)

A ball of radius (in range_unit) about center.

Mera.SphericalShellType
SphericalShell(r_in, r_out; center=[:bc], range_unit=:kpc)

The shell r_in ≤ |r| ≤ r_out (in range_unit) about center.

Mera.StructureNodeType
StructureNode

One node of a StructureTree: id, parent (0 at a root), children (ids), an is_leaf flag, the peak field value in its subtree, the base level at which it forms (the saddle where it merges into its parent, or the threshold at a root), and member counts n_self (points it owns directly — nonzero only for leaves) and n_subtree (points in the whole subtree).

Mera.StructureTreeType
StructureTree

The multi-scale hierarchy produced by a Dendrogram finder (clumpfind(obj, …; hierarchy=true)): nodes (a vector of StructureNode, indexable by node id) and roots (top-level node ids, one per disconnected region). Leaves are the finest structures (density peaks pruned by min_delta); branches are the levels at which they merge. Accessors: roots, leaves, children, parent.

Mera.ThreadSafeProgressType
ThreadSafeProgress

Mutable struct for managing progress bar updates across multiple threads. Prevents race conditions when multiple threads try to update progress simultaneously.

Fields

  • progress: ProgressMeter.Progress object for display
  • current_file: Name of file currently being processed
  • completed: Number of files completed so far
  • total: Total number of files to process
  • lock: ReentrantLock for thread synchronization
Mera.ThreadSafeProgressMethod
ThreadSafeProgress(total::Int) -> ThreadSafeProgress

Constructor for thread-safe progress tracker. Initializes progress bar with appropriate settings for file conversion display.

Progress Bar Configuration

  • Shows completion ratio [completed/total]
  • Updates every 0.5 seconds to avoid excessive output
  • 40-character progress bar for good visual feedback
  • Shows processing speed (files/second)
Mera.ThresholdFoFType
ThresholdFoF(field=:rho; threshold, linking_length, threshold_unit=:standard, backend=CellLinkedList)

Friends-of-friends finder: members with field ≥ threshold are linked into a clump when within linking_length of one another. The classic, fast connectivity finder (Davis et al. 1985).

Mera.VirialBelowType
VirialBelow(alpha)

Keep clumps with virial parameter alpha_vir < alpha. Requires a Bound in the chain (or boundedness=true) so alpha_vir is computed; a non-finite alpha_vir fails the test.

Mera.WStatTypeType

Mutable Struct: Contains the output statistics returned by wstat

Mera.MaskTypeType

Union Type: Mask-array that is of type Bool or BitArray MaskType = Union{Array{Bool,1},BitArray{1}}

Documentation Functions

Mera.JLD2flagMethod
JLD2flag(first_flag::Bool) -> (Bool, Symbol)

Determines the appropriate file mode for JLD2 operations.

  • First write operation: creates new file (:write mode)
  • Subsequent operations: append to existing file (:append mode)

Returns updated first_flag and corresponding file mode symbol.

Mera.__init__Method
__init__()

Announce Mera on load. In an interactive session (REPL / Jupyter) print the ASCII banner with the version; otherwise emit a single greppable @info "Mera vX.Y.Z" line (stderr, silenceable, doesn't pollute stdout) so scripts / tests / CI get a clean one-line marker instead of the art. The version comes from pkgversion, so it always tracks Project.toml. (Top-level printlns would only run during precompilation, so this lives in __init__ instead.)

Mera._lz4_typemapMethod
_lz4_typemap()

Create a JLD2 typemap entry for handling old LZ4FrameCompressor objects.

Old files have LZ4FrameCompressor with header::TranscodingStreams.Memory field, new code expects header::Vector{UInt8}. We map the old type directly to the current type — JLD2 constructs a fresh default compressor, which works because the compressor is just metadata (the actual compressed data is separate).

Mera.absorption_mapMethod
absorption_map(dataobject; kappa, sd_unit=:g_cm2, kappa_unit=:standard, verbose=true,
               <projection view kwargs>) -> NamedTuple

Continuum absorption map along the line of sight. Returns the optical depth τ = ∫κρ dl, the transmission e^{-τ}, the absorbed fraction 1 - e^{-τ}, the column density sd, and the column-effective opacity kappa_eff (= τ/Σ).

kappa sets the opacity and may be

  • a Real — a constant (grey) opacity, τ = κ·Σ (e.g. kappa=dust_opacity(0.55));
  • a Symbol — a per-cell opacity field: any getvar field, an add_field- registered field, or a raw data column (e.g. a stored metallicity). τ = ⟨κ⟩_mass·Σ, which is exactly ∫κρ dl;
  • an AbstractVector — a per-cell opacity, one value per cell (full data length), in kappa_unit.

So the opacity can depend on metallicity, gas phase, temperature or ionization (build the per-cell κ from getvar), and on wavelength (via dust_opacity). Units: κ must be inverse to sd_unit (cm²/g for the default sd_unit=:g_cm2) so τ is dimensionless; for a Symbol/vector, kappa_unit is the unit those values are in (default :standard, i.e. already cm²/g).

All projection view/region keywords pass through (los/up, direction, inclination/azimuth, center, range_unit, xrange/…, res, lmax).

a = absorption_map(gas; kappa=210.0)                         # grey, dust-like
a = absorption_map(gas; kappa=dust_opacity(0.55))            # grey at V band

# metallicity-dependent dust opacity, per cell (κ ∝ Z, with a temperature dust-sublimation cutoff)
κcell = dust_opacity(0.55) .* getvar(gas,:metals) ./ 0.0134 .* (getvar(gas,:T,:K) .< 1500.0)
a = absorption_map(gas; kappa=κcell, los=fr.los, up=fr.up, center=fr.center)

# phase-specific (only molecular gas absorbs) via a registered field, or a raw column
a = absorption_map(gas; kappa=:my_kappa_field)

Returns (tau, transmission, absorbed, sd, kappa_eff, sd_unit, extent, los, up, center, pixsize, info). See also emission_map (the emission counterpart) and dust_opacity.

Mera.add_fieldMethod
add_field(name::Symbol, compute::Function; depends_on=Symbol[], datatypes=:hydro,
          unit::Symbol=:standard, description::String="")

Register a user-defined derived field that then behaves like any built-in getvar quantity — it works in getvar, and therefore in projection, profile, phase, etc.

  • compute(dataobject, deps) — your kernel. deps is a Dict{Symbol,Vector} holding the arrays of depends_on (already centered / masked consistently). Return the field in code units; the requested unit (or this field's default unit) is applied for you.
  • depends_on — the variables your kernel needs (built-in or other user fields). These are also recorded in the dependency graph so getvar_requirements (and the read-only-what-you-need logic in project/quicklook) cover your field.
  • datatypes — a kind symbol or collection of them: :hydro, :gravity, :rt, :particle, :clump.
  • unit — default unit symbol (must be a field of info.scale, or :standard).
add_field(:vmag2, (o, d) -> d[:vx].^2 .+ d[:vy].^2 .+ d[:vz].^2; depends_on=[:vx,:vy,:vz])
getvar(gas, :vmag2)
projection(gas, :vmag2)

See also delete_field, list_fields.

Mera.add_unitMethod
add_unit(name::Symbol, factor::Real)

Register a custom unit: a value in code units is multiplied by factor to convert to this unit. The name then works anywhere a unit symbol is accepted — in add_field (as the field's default unit), and in getvar(obj, var, name).

add_unit(:Msun_per_yr, 1.0)                      # e.g. for an SFR-like custom field
add_field(:mdot, (o,d)->d[:rho]; depends_on=[:rho], unit=:Msun_per_yr)

See also delete_unit, list_units.

Mera.amroverviewMethod
amroverview(dataobject::GravDataType; verbose::Bool=true)

Get the number of cells and CPUs per AMR level for gravity data. Returns an IndexedTable with columns level, cells, cellsize, and optionally cpus.

Mera.amroverviewMethod
amroverview(dataobject::HydroDataType; verbose::Bool=true)
amroverview(dataobject::GravDataType; verbose::Bool=true) 
amroverview(dataobject::PartDataType; verbose::Bool=true)

Generate an overview table showing the distribution of cells/particles across AMR levels.

Arguments

  • dataobject: AMR data object (HydroDataType, GravDataType, or PartDataType)
  • verbose::Bool=true: Display progress information during calculation

Returns

  • IndexedTable: Table with columns:
    • :level: AMR refinement level
    • :cells/:particles: Number of cells or particles at each level
    • :cellsize: Physical size of cells at each level (Hydro/Grav only)
    • :cpus: Number of CPU domains at each level (if CPU info available)

Examples

```julia

Basic AMR overview for hydro data

gas = gethydro(info, verbose=false) table = amroverview(gas)

Silent processing

table = amroverview(gas, verbose=false)

Mera.amroverviewMethod
amroverview(dataobject::PartDataType; verbose::Bool=true)

Get the number of particles and CPUs per AMR level for particle data. Returns an IndexedTable with columns level, particles, and optionally cpus.

Mera.analyze_amr_structureMethod
analyze_amr_structure(gas_data) → Dict

Perform comprehensive analysis of AMR data structure and refinement hierarchy.

Analyzes the adaptive mesh refinement structure to understand data complexity, refinement level distribution, and spatial extent. This information provides essential context for interpreting benchmark performance results.

Returns

Dictionary containing:

  • total_cells: Total number of AMR cells
  • data_size_gb: Memory footprint in gigabytes
  • level_range: (minlevel, maxlevel) refinement range
  • level_count: Number of distinct refinement levels
  • level_stats: Per-level cell counts and percentages
  • complexity_factor: Normalized complexity metric for performance scaling

Analysis Components

  1. Cell Count Statistics: Total cells and memory usage
  2. Refinement Level Distribution: Cell counts per refinement level
  3. Spatial Extent Analysis: Coordinate ranges and effective resolution
  4. Performance Metrics: Complexity weighting for benchmark interpretation

Example

gas_data = loaddata(300, "/path/to/ramses/", :hydro)
amr_stats = analyze_amr_structure(gas_data)
println("AMR complexity factor: $(amr_stats["complexity_factor"])")
Mera.average_mweighted_metaprogMethod

Metaprogramming-optimized mass-weighted average with template generation. Fuses mass and variable data access for optimal performance.

Mera.average_velocityMethod

Calculate the average velocity (w/o mass-weight) of any ContainMassDataSetType:

average_velocity(dataobject::ContainMassDataSetType; unit::Symbol=:standard, weighting::Symbol=:mass, mask::MaskType=[false])

return Tuple{Float64, Float64, Float64,}

Arguments

Required:

  • dataobject: needs to be of type: "ContainMassDataSetType"

Optional Keywords:

  • unit: the unit of the result (can be used w/o keyword): :standard (code units) :kms, :ms, :cm_s (of typye Symbol) ..etc. ; see for defined velocity-scales viewfields(info.scale)
  • weighting: use different weightings: :mass (default), :volume (hydro), :no
  • mask: needs to be of type MaskType which is a supertype of Array{Bool,1} or BitArray{1} with the length of the database (rows)
Mera.baryon_fractionMethod
baryon_fraction(; label="baryon_fraction")

Cross-datatype card: (gas + stars) / (gas + stars + dark matter), reading hydro + particles.

Mera.batch_convert_meraMethod
batch_convert_mera(input_dir::String, output_dir::String, 
                           start_output::Int, end_output::Int;
                           requested_threads::Int=Threads.nthreads(),
                           safety_margin::Float64=DEFAULT_SAFETY_MARGIN,
                           min_threads::Int=DEFAULT_MIN_THREADS,
                           max_threads::Int=DEFAULT_MAX_THREADS,
                           skip_existing::Bool=true,
                           show_confirmation::Bool=true,
                           compress=nothing) -> Dict

Main function for safe multithreaded batch conversion with active safety margin monitoring.

This function coordinates the entire conversion process including:

  1. System resource validation and safety checks
  2. File discovery and filtering by output number range
  3. Thread count optimization based on system constraints
  4. User confirmation and information display
  5. Multithreaded conversion with real-time monitoring
  6. Comprehensive results reporting and recommendations

Parameter Details

Required Parameters

  • input_dir: Source directory containing old JLD2 files with version issues
  • output_dir: Destination directory for converted files (created if doesn't exist)
  • start_output: Starting output number for conversion range (inclusive)
  • end_output: Ending output number for conversion range (inclusive)

Performance Tuning Parameters

  • requested_threads: Desired number of conversion threads (default: all available)
  • safety_margin: Memory usage threshold as decimal 0.0-1.0 (default: 0.8 = 80%)
  • min_threads: Minimum thread count even under resource constraints (default: 1)
  • max_threads: Maximum thread count regardless of system capacity (default: 64)

Behavior Control Parameters

  • skip_existing: Skip files that already exist in output directory (default: true)
  • show_confirmation: Display user confirmation prompt before starting (default: true)
  • compress: Compression codec for the output files, matching savedata's API (default: nothingLZ4FrameCompressor()). Pass false to write uncompressed files, or a specific codec instance (LZ4FrameCompressor(), ZlibCompressor(), Bzip2Compressor()) for finer control.

Safety Margin System

The safety_margin parameter is now actively used throughout the process:

Pre-Conversion Phase

  • Validates current system memory usage
  • Adjusts thread recommendations based on available memory within safety limits
  • Warns user if current usage already exceeds margin

During Conversion Phase

  • Monitors memory usage before each file load operation
  • Checks memory after data loading (peak usage point)
  • Triggers automatic garbage collection on violations
  • Counts total violations for reporting

Post-Conversion Phase

  • Reports final memory state and violation statistics
  • Provides recommendations for future conversions based on violation patterns

Return Value

Returns comprehensive dictionary with conversion statistics:

  • success: Number of files successfully converted
  • failed: Number of files that failed conversion
  • skipped: Number of files skipped (already existed)
  • safety_violations: Number of times memory exceeded safety margin
  • conversion_time: Total time spent in conversion (seconds)
  • threads_used: Actual number of threads used
  • final_memory_usage_percent: Memory usage percentage at completion

Error Handling Strategy

The function handles errors gracefully:

  • Individual file failures don't stop the batch
  • Out-of-memory errors receive specific guidance
  • System resource violations trigger automatic recovery
  • All errors are logged with specific context

Example Usage

Basic conversion with default safety settings: results = batchconvertmera("/data/old", "/data/new", 100, 200)

Conservative conversion for large files: results = batchconvertera("/data/old", "/data/new", 100, 200; requestedthreads=4, safetymargin=0.9)

High-performance conversion with monitoring: results = batchconvertmera("/data/old", "/data/new", 100, 200; requestedthreads=16, safetymargin=0.7, skip_existing=false)

Mera.batchesMethod

Split 1:nfiles into chunks of size ≤ chunk.

Mera.bellFunction
bell(sound = nothing)

Play a short notification sound — e.g. when a long calculation finishes.

Pick the sound in any of these ways (first match wins):

  1. by namebell(:chime) (a Symbol or String);
  2. by numberbell(2) (the position shown by bell(:list), also a numeric string like bell("2"));
  3. a default file — put a sound name or number on the first line of ~/bell.txt (the same home-folder pattern notifyme uses with email.txt / zulip.txt);
  4. the built-in fallback:strum (the original Mera sound).

List the bundled sounds (with their numbers) using bell(:list): arpeggio, bell, bird, bloop, bongo, chime, coin, coindrop, cosmic, ding, done, door, frog, gong, knock, oscillations, owl, strum, whistle.

You can also drop your own *.wav into the package's src/sounds/ folder and select it by its file name or number.

bell()            # default sound (from ~/bell.txt if present, else :strum)
bell(:gong)       # a deep blooming gong
bell("chime")     # a glassy three-note chime
bell(4)           # the 4th sound in bell(:list)
bell(:list)       # print the numbered catalogue of available sounds
Mera.benchmark_buffer_sizesMethod
benchmark_buffer_sizes(simulation_path::String, output_num::Int; 
                      test_sizes=[32768, 65536, 131072, 262144], verbose=true)

Benchmark different buffer sizes to find the optimal setting for this specific simulation.

Mera.benchmark_mera_ioMethod
benchmark_mera_io(simulation_path::String, output_num::Int; 
                 test_sizes=["32KB", "64KB", "128KB", "256KB"])

Benchmark different I/O configurations to find optimal settings for your specific simulation.

This function tests various buffer sizes with your actual data to determine which configuration gives the best performance on your system.

Arguments

  • simulation_path: Path to your RAMSES simulation directory
  • output_num: Output number to test with
  • test_sizes: Array of buffer sizes to test (as strings)

Returns

  • Dictionary with benchmark results and recommended optimal settings

Example

# Standard benchmark
results = benchmark_mera_io("/path/to/simulation", 300)

# Custom buffer sizes to test
results = benchmark_mera_io("/path/to/simulation", 300, 
                           test_sizes=["64KB", "128KB", "256KB", "512KB"])

# Access results
optimal_buffer = results["optimal_buffer_size"]
performance_gain = results["performance_improvement"]

What it does

  1. Tests each buffer size with your actual simulation data
  2. Measures getinfo() and gethydro() performance
  3. Identifies the optimal buffer size for your system
  4. Automatically applies the best settings
  5. Returns detailed performance comparison
Mera.benchmark_multi_variable_projectionFunction
benchmark_multi_variable_projection(gas_data, n_threads::Int, n_runs::Int=10) → Dict

Execute multi-variable projection benchmark testing simultaneous computation of 10 hydro variables.

Performs comprehensive timing analysis of multi-variable projections computing 10 simultaneous hydro variables including velocity components, velocity dispersion, and cylindrical coordinates. This benchmark tests the threading efficiency for complex projection scenarios typical in astrophysical analysis workflows.

Variable Set (10 Variables)

  • Velocity: :v (3D velocity field analysis)
  • Velocity Dispersion: σ:, σx, :σy, :σz (turbulence and kinematic structure)
  • Cylindrical Coordinates: :vrcylinder, :vϕcylinder, σrcylinder, σϕcylinder (disk dynamics)
  • Thermal Soundspeed: :cs

Methodology

  • Projection Type: Simultaneous multi-variable calculation (realistic workflow)
  • Threading: Shared memory parallelization across variables and spatial bins
  • Statistics: several repetitions with comprehensive error analysis

Performance Characteristics

Multi-variable projections exhibit different scaling behavior than single-variable:

  • Memory Scaling: higher memory usage due to multiple output arrays
  • Threading Efficiency: May differ due to increased memory bandwidth requirements
  • Computational Complexity: Higher arithmetic intensity but better cache reuse

Arguments

  • gas_data: HydroDataType object containing AMR hydro simulation data
  • n_threads::Int: Number of threads for parallel computation
  • n_runs::Int=10: Statistical repetitions for robust measurement

Returns

Dictionary with detailed performance analysis:

  • mean_time, std_time: Multi-variable projection timing statistics
  • mean_memory: Peak memory usage
  • success_rate: Reliability metric (target: >95% for complex operations)
  • coefficient_variation: Precision indicator for multi-variable timing

Performance Comparison

Compare with single-variable results to understand:

  • Threading efficiency differences between simple/complex projections
  • Memory bandwidth limitations in multi-variable scenarios
  • Optimal thread counts for different projection complexities

Example

# Multi-variable benchmark for threading analysis
result = benchmark_multi_variable_projection(gas_data, 8, 10)

# Compare with single-variable efficiency
single_result = benchmark_single_variable_projection(gas_data, 8, 10)
efficiency_ratio = single_result["mean_time"] / result["mean_time"] * 10
println("Multi-variable efficiency: $(efficiency_ratio) variables per single-variable time")
Mera.benchmark_projection_hydroFunction
benchmark_projection_hydro(gas_data, thread_counts::Vector{Int}, n_runs::Int=10, output_file::String="") → Dict

Execute comprehensive AMR hydro projection benchmark with robust statistical analysis.

This function serves as the main coordinator for hydro projection performance testing. It performs AMR structure analysis, data quality validation, executes both single-variable and multi-variable projection benchmarks across specified thread counts, and exports results in multiple formats with comprehensive statistical analysis.

Benchmark Methodology

  • Single-Variable Test: Surface density projection (:sd → Msun/pc²)
  • Multi-Variable Test: 10 simultaneous variable projections: vars = [:v, :σ, :σx, :σy, :σz, :vrcylinder, :vϕcylinder, :σrcylinder, :σϕcylinder, :cs]
  • Statistical Robustness: several repetitions per configuration with coefficient of variation
  • Quality Control: Success rate monitoring (>80% threshold for reliable data)
  • Memory Profiling: Peak memory usage and garbage collection analysis

Threading Analysis

Evaluates performance across thread counts with derived metrics:

  • Speedup: Performance improvement vs single-threaded execution
  • Efficiency: Speedup per thread (percentage of ideal scaling)
  • Memory Scaling: Memory usage patterns across thread configurations

Output Files Generated

  • {output_file}.csv: Structured data for spreadsheet analysis and plotting
  • {output_file}.json: Machine-readable structured data for programmatic access
  • {output_file}_summary.txt: Human-readable performance report with insights

Arguments

  • gas_data: HydroDataType object from loaddata() or gethydrodata()
  • thread_counts::Vector{Int}: Thread counts to benchmark [1, 2, 4, 8, 16, ...]
  • n_runs::Int=10: Statistical repetitions per configuration (10 for robust analysis)
  • output_file::String="": Output filename base (auto-generated timestamp if empty)

Returns

Dictionary containing complete benchmark results with keys:

  • n_threads, test_type, mean_time, std_time, speedup, efficiency
  • mean_memory, success_rate, min_time, max_time, n_runs

Example Usage

# Load RAMSES hydro data
gas_data = loaddata(300, "/path/to/ramses/output/", :hydro)

# Run comprehensive benchmark (single + multi-variable)
results = benchmark_projection_hydro(gas_data, [1, 2, 4, 8, 16], 10, "performance_test")

# Results saved as:
# - performance_test.csv (for plotting with plot_results.jl)
# - performance_test.json (for programmatic analysis)  
# - performance_test_summary.txt (human-readable report)

Performance Insights

The benchmark automatically analyzes threading efficiency and provides guidance:

  • Identifies optimal thread counts for your system and data size
  • Detects threading bottlenecks and memory constraints
  • Quantifies single vs multi-variable projection performance differences
  • Provides statistical confidence intervals for all measurements

Integration Workflow

  1. Data Loading: Use Mera's loaddata() for your RAMSES simulation
  2. Benchmarking: Execute this function with desired thread counts
  3. Visualization: Use plot_results.jl to create performance dashboards
  4. Analysis: Review summary.txt for optimization recommendations
Mera.benchmark_single_variable_projectionFunction
benchmark_single_variable_projection(gas_data, n_threads::Int, n_runs::Int=10) → Dict

Execute single-variable surface density projection benchmark with robust statistical analysis.

Performs high-precision timing measurements of surface density (:sd → Msun/pc²) projections using the specified thread count. Implements comprehensive statistical analysis including warm-up runs, outlier detection, and memory profiling for reliable performance data.

Methodology

  • Variable: Surface density (:sd) - most common astronomical observable
  • Unit: Msun/pc² (solar masses per square parsec) - standard surface density unit
  • Resolution: 128×128 projection grid (balanced performance/accuracy)
  • Statistics: several repetitions with coefficient of variation analysis
  • Quality Control: Success rate monitoring and outlier detection

Performance Monitoring

  • Timing: Microsecond-precision measurement with warm-up runs
  • Memory: Peak memory usage tracking during projection execution
  • GC Analysis: Garbage collection overhead monitoring
  • Progress: Real-time statistics with running averages and CV calculation

Arguments

  • gas_data: HydroDataType object containing AMR simulation data
  • n_threads::Int: Number of threads for projection calculation
  • n_runs::Int=10: Statistical repetitions (10 for robust analysis)

Returns

Dictionary with comprehensive performance metrics:

  • mean_time, std_time, min_time, max_time: Timing statistics (seconds)
  • coefficient_variation: Measurement precision indicator (target: <5%)
  • mean_memory: Average peak memory usage (GiB)
  • mean_gc_time: Average garbage collection overhead (seconds)
  • success_rate: Fraction of successful runs (1.0 = 100% success)
  • n_runs: Number of statistical repetitions performed

Example

# Single-threaded surface density benchmark
result = benchmark_single_variable_projection(gas_data, 1, 10)
println("Mean execution time: $(result["mean_time"]) seconds")
println("Measurement precision: $(result["coefficient_variation"]*100)%")
Mera.build_camera_basisFunction
build_camera_basis(los, up=nothing; roll=0.0) -> (right, up, w)

Construct a right-handed orthonormal camera basis from a line-of-sight vector los (the viewing direction) and an optional up hint.

Returns three unit 3-vectors (right, up, w) where w = los/‖los‖ is the viewing direction, and right, up span the image plane (image x = right, image y = up). The basis is right-handed with right × up = w.

If up is nothing — or (anti)parallel to los — a deterministic auto-up is chosen (the world axis least parallel to los), so the result is fully reproducible.

roll (radians) rotates the image plane about the line of sight — i.e. it sets the orientation of the image on the "sky" (the astronomical position angle / camera roll). It leaves w unchanged and rotates (right, up) together, so it composes with any way of choosing los.

Convention check: los=[0,0,1], up=[0,1,0]right=[1,0,0], up=[0,1,0], matching the axis-aligned direction=:z mapping (image x→sim x, image y→sim y).

Mera.bulk_velocityMethod

Calculate the average velocity (w/o mass-weight) of any ContainMassDataSetType:

bulk_velocity(dataobject::ContainMassDataSetType; unit::Symbol=:standard, weighting::Symbol=:mass, mask::MaskType=[false])

return Tuple{Float64, Float64, Float64,}

Arguments

Required:

  • dataobject: needs to be of type: "ContainMassDataSetType"

Optional Keywords:

  • unit: the unit of the result (can be used w/o keyword): :standard (code units) :kms, :ms, :cm_s (of typye Symbol) ..etc. ; see for defined velocity-scales viewfields(info.scale)
  • weighting: use different weightings: :mass (default), :volume (hydro), :no
  • mask: needs to be of type MaskType which is a supertype of Array{Bool,1} or BitArray{1} with the length of the database (rows)
Mera.bulk_velocity_metaprogMethod

Metaprogramming-optimized bulk velocity with compile-time weighting dispatch. Generates specialized code for each weighting scheme at compile time.

Mera.calculate_safe_thread_countMethod
calculate_safe_thread_count(requested_threads::Int; 
                           safety_margin::Float64=DEFAULT_SAFETY_MARGIN,
                           min_threads::Int=DEFAULT_MIN_THREADS,
                           max_threads::Int=DEFAULT_MAX_THREADS) -> Int

Calculate the maximum safe number of threads based on system constraints and current state. This function now actively uses the safety_margin to provide intelligent recommendations.

Algorithm

  1. Check current memory usage against safety margin
  2. Calculate available memory within safety limits
  3. Apply memory-based adjustment factor if resources are constrained
  4. Respect system core count and user-defined limits
  5. Ensure result stays within min/max bounds

Parameters

  • requested_threads: User's desired thread count
  • safety_margin: Maximum memory usage threshold (0.0-1.0)
  • min_threads: Minimum allowable threads (safety floor)
  • max_threads: Maximum allowable threads (performance ceiling)

Returns

Integer thread count that balances performance with system safety

Mera.calibrate!Method
calibrate!(output; path=".", budget=200_000) -> CostModel

Actively calibrate the cost model for this machine/output by running a tiny report (one coarse level + small projection/phase/profile/scalar) and learning the timing coefficients. ~0.5–3 s, once. (The model also self-calibrates passively after every real report.)

Mera.cell_shiftMethod
cell_shift(level::Int, value::Real, cell::Bool)

Legacy compatibility function for shell region functions.

This function provides backward compatibility with older shell region code that used cellshift calls. The newer geometry helper functions (getradius*, getheight_*) handle cell vs point-based selection internally, so this function simply returns the input value unchanged.

Arguments

  • level::Int: AMR level (unused in current implementation)
  • value::Real: The input value to be returned
  • cell::Bool: Cell vs point selection flag (unused in current implementation)

Returns

  • Real: The input value unchanged

Note

This function exists for compatibility with legacy shell region functions. New code should use the geometry helper functions directly.

Mera.center_ofMethod
center_of(data; method=:com, unit=:standard, mask=[false])

Find the centre of an object and return [x, y, z] in unit.

  • method=:com — mass-weighted centre of mass (delegates to center_of_mass).
  • method=:densest (:peak) — position of the densest hydro cell (needs hydro data).

mask (a Bool/BitArray over the cells/particles) restricts the calculation.

Mera.center_of_massMethod

Calculate the center-of-mass of any ContainMassDataSetType:

center_of_mass(dataobject::ContainMassDataSetType; unit::Symbol=:standard, mask::MaskType=[false])

return Tuple{Float64, Float64, Float64,}

Arguments

Required:

  • dataobject: needs to be of type: "ContainMassDataSetType"

Optional Keywords:

  • unit: the unit of the result (can be used w/o keyword): :standard (code units), :Mpc, :kpc, :pc, :mpc, :ly, :au , :km, :cm (of typye Symbol) ..etc. ; see for defined length-scales viewfields(info.scale)
  • mask: needs to be of type MaskType which is a supertype of Array{Bool,1} or BitArray{1} with the length of the database (rows)
Mera.center_of_massMethod

Calculate the joint center-of-mass of any HydroPartType:

center_of_mass(dataobject::Array{HydroPartType,1}, unit::Symbol; mask::MaskArrayAbstractType=[[false],[false]])

return Tuple{Float64, Float64, Float64,}

Arguments

Required:

  • dataobject: needs to be of type: "Array{HydroPartType,1}""

Optional Keywords:

  • unit: the unit of the result (can be used w/o keyword): :standard (code units), :Mpc, :kpc, :pc, :mpc, :ly, :au , :km, :cm (of typye Symbol) ..etc. ; see for defined length-scales viewfields(info.scale)
  • mask: needs to be of type MaskArrayAbstractType which contains two entries with supertype of Array{Bool,1} or BitArray{1} and the length of the database (rows)
Mera.center_of_mass_joint_metaprogMethod

Metaprogramming-optimized joint center of mass for multiple datasets. Uses template-based loop generation with compile-time optimization.

Mera.center_of_mass_metaprogMethod

Metaprogramming-optimized center of mass with fused mass-weighted operations. Uses compile-time template generation for maximum performance.

Mera.check_available_filesMethod
check_available_files(input_dir::String) -> Dict

Analyze directory contents and provide comprehensive file information. Used for validation and user feedback about available data.

Returns Dictionary with keys:

  • "files": Vector of valid JLD2 filenames
  • "range": Tuple of (minoutput, maxoutput) or nothing if no files
  • "gaps": Vector of missing output numbers within the range
  • "total": Total count of valid files

Gap Detection Algorithm

Identifies missing files in the sequence, which can indicate:

  • Incomplete simulation runs
  • File transfer errors
  • Storage problems

This helps users identify data integrity issues before conversion

Mera.check_safety_margin_violationMethod
check_safety_margin_violation(safety_margin::Float64) -> Bool

Determine if current system memory usage exceeds the configured safety margin. This is the core safety check function that prevents system overload.

Arguments

  • safety_margin: Decimal value (0.0-1.0) representing maximum allowed memory usage

Returns

  • true if memory usage exceeds safety margin (dangerous situation)
  • false if memory usage is within safe limits

Example

  • safety_margin = 0.8 means allow up to 80% memory usage
  • If current usage is 85%, this returns true (violation)
Mera.checkoutputsFunction

Get the existing simulation snapshots in a given folder

  • returns field outputs with Array{Int,1} containing the output-numbers of the existing simulations
  • returns field miss with Array{Int,1} containing the output-numbers of empty simulation folders
  • returns field path as String
checkoutputs(path::String="./"; verbose::Bool=true)
return CheckOutputNumberType

Examples

# Example 1:
# look in current folder
julia> N = checkoutputs();
julia> N.outputs
julia> N.miss
julia> N.path

# Example 2:
# look in given path
# without any keyword
julia>N = checkoutputs("simulation001");
Mera.clump_mass_fractionMethod
clump_mass_fraction(; label="clump_mass_fraction")

Cross-datatype card: total clump mass / total gas mass, reading clumps + hydro.

Mera.clump_massfunctionMethod
clump_massfunction(cat::ClumpCatalog; nbins=20, scale=:log, cumulative=false)
    -> (mass, N)

The clump mass function. Differential (default): histogram of clump masses into nbins (scale=:log ⇒ log-spaced bins) — returns (bin_centres, counts). Cumulative (cumulative=true): returns (sorted_mass, N(≥M)).

Mera.clump_recoveryMethod
clump_recovery(found_labels, true_labels; background=0) -> NamedTuple

Compare a found clump segmentation against a known ground truth, label-for-label over the same points. Returns (; ari, completeness, purity, merit, n_found, n_true, n_points):

  • ariAdjusted Rand Index (Hubert & Arabie 1985): 1 = perfect agreement, 0 = chance-level, can be slightly negative. The standard clustering-quality metric.
  • completeness — mass/count-weighted fraction of each true clump captured by its best-matching found clump, averaged over true clumps (1 = every true clump is fully contained in one found clump).
  • purity — the same from the found side (1 = no found clump mixes two true clumps).
  • merit — mean bijective merit Σ max_i n_ij²/(|found_i|·|true_j|) (Srisawat+2013 "SUSSING"), rewarding one-to-one matches.

background (default 0) is the label for unassigned points; those points are excluded from completeness/purity/merit (but kept in ari, which scores the full partition). Both label vectors must be the same length and indexed by the same points.

m = clump_recovery(found_labels, true_labels)
m.ari            # ≈ 1 when the finder recovers the input clumps
Mera.clumpfindFunction
clumpfind(obj::HydroPartType, field=:rho; threshold, linking_length,
          threshold_unit=:standard, pos_unit=:kpc, mass_unit=:Msol,
          min_members=1, mask=[false], boundedness=false, bound_only=false,
          egrav=:approx, direct_max=2000, deblend=false, peak_min_distance=2·linking_length,
          substructure=false, sub_min_members=min_members) -> ClumpCatalog

Convenience form of the AbstractFinder method: builds a ThresholdFoF from field/threshold/linking_length and forwards every other keyword. Existing scripts keep working unchanged; see the finder method above for the full keyword reference.

gas = gethydro(getinfo(output, path))
cat = clumpfind(gas, :rho; threshold=1e2, threshold_unit=:nH, linking_length=0.2)   # 0.2 kpc
bound = clumpfind(gas, :rho; threshold=1e2, threshold_unit=:nH, linking_length=0.2,
                  boundedness=true, bound_only=true, deblend=true)
Mera.clumpfindMethod
clumpfind(components::AbstractVector; linking_length, pos_unit=:kpc, mass_unit=:Msol,
          min_members=1, boundedness=false, bound_only=false, egrav=:approx,
          direct_max=2000, softening=0.0, iterative_unbinding=false) -> ClumpCatalog

Multi-field structure finder: pre-select points from several components and link them with a single friends-of-friends pass, so over-densities in gas + stars + dark matter are found together. Each component is a NamedTuple (obj, field, threshold, name [, threshold_unit, mask]); its points with field ≥ threshold (and optional mask(obj)) join the common cloud tagged by name. Per clump the catalog reports total mass, com, radius, member count, and a components breakdown (name=(mass=…, n=…), …) per source.

boundedness=true adds the combined-cloud energetics (e_kin, e_therm, e_mag, e_grav, alpha_vir, bound) computed over all species together (each contributing its own mass and velocity; gas also its thermal/magnetic support), so the bound test uses the full self-gravity of gas + stars + DM while the components breakdown remains the per-species mass budget. egrav, direct_max, softening, iterative_unbinding and bound_only behave as in the single-object form.

cat = clumpfind([
    (obj=gas,   field=:rho,  threshold=1e2, threshold_unit=:nH, name=:gas),
    (obj=parts, field=:mass, threshold=0.0, name=:stars, mask = o->getvar(o,:birth).>0),
    (obj=parts, field=:mass, threshold=0.0, name=:dm,    mask = o->getvar(o,:birth).<=0),
]; linking_length=0.5, boundedness=true)
cat[1].components.gas.mass        # gas mass in the most massive structure
cat[1].bound                      # self-bound across all three species?
Mera.clumpfindMethod
clumpfind(map::DataMapsType, field; threshold, connectivity=8, min_pixels=1) -> ClumpCatalog

2D connected-component finder on a projection map. Pixels with map[field] ≥ threshold are grouped by connectivity (4 or 8). Per region it returns pixel count n_members, mass (area-integral Σ value · pixel_area, exact for a surface-density map), com (value-weighted centroid), peak & peak_pos, and radius — positions in the map's extent units.

Mera.clumpfindMethod
clumpfind(obj::HydroPartType, finder::AbstractFinder; pos_unit=:kpc, mass_unit=:Msol,
          min_members=1, mask=[false], boundedness=false, bound_only=false,
          egrav=:approx, direct_max=2000, softening=0.0, iterative_unbinding=false,
          deblend=false, peak_min_distance=…, substructure=false, sub_min_members=min_members,
          tidal=false, gravity=nothing, tidal_sample=3.0, hierarchy=false,
          max_threads=Threads.nthreads()) -> ClumpCatalog

3D structure finder driven by any AbstractFinder finder value (one of the seven: ThresholdFoF, DensityWatershed, Dendrogram, GraphSegFinder, HDBSCANFinder, PhaseSpaceFoF, PersistenceFinder; it carries the field/threshold/linking-length and selects the algorithm). Per clump it returns member count, mass, centre of mass com, peak field value and peak_pos, and radius (max member distance from the COM) — positions in pos_unit, mass in mass_unit.

  • boundedness=true adds per-clump energetics (cgs): e_kin (COM-frame kinetic), e_therm (thermal, gas), e_grav (binding energy), alpha_vir = 2·e_kin/|e_grav|, and a bound flag (e_kin + e_therm < |e_grav|). bound_only=true keeps only self-bound clumps. The potential is set by egrav: :approx3/5·GM²/R (biased, fast); :direct ⇒ exact pairwise sum up to direct_max members; :tree ⇒ Barnes–Hut octree, O(N log N), accurate at any N (Barnes & Hut 1986). softening (in pos_unit) softens the kernel 1/√(r²+ε²).
  • iterative_unbinding=true runs SUBFIND-style unbinding (Springel+2001): members with positive total energy in the bulk-velocity frame are stripped iteratively until convergence, so each clump's reported membership/mass is its self-bound subset. Implies the boundedness analysis.
  • deblend=true/:peak splits merged clumps at their density peaks (members assigned to the nearest peak); deblend=:watershed instead assigns by density-descending basins. Peaks are separated by peak_min_distance (in pos_unit). (Equivalent to using a DensityWatershed finder.)
  • substructure=true builds a bound-substructure tree: each top-level clump is split into density basins (watershed) and the gravitationally self-bound ones (≥ sub_min_members) are attached as nested subclumps (with n_subclumps). Implies the boundedness analysis.
  • tidal (needs substructure=true) truncates each sub-clump at its tidal/Hill radius in the host: tidal=true uses the analytic Jacobi radius, tidal=:tensor the least-squares tidal-tensor radius from a gravity object (getgravity); tidal_sample scales the host sampling region.
  • hierarchy=true (for a Dendrogram finder) also returns the multi-scale merger tree in cat.tree (a StructureTree).
  • max_threads caps the threads used for the per-clump analysis (deterministic regardless of count).
  • validators — a composable chain of value-typed acceptance criteria (MinMembers, Bound, VirialBelow, MassAbove, Custom) that a clump must all satisfy (an AND). It is a clearer alternative to the boundedness kwargs: a Bound in the chain configures the boundedness pass (potential, iterative unbinding) and keeps only self-bound clumps; the predicate validators filter the catalog. A non-empty validators overrides boundedness/bound_only/min_members/egrav/iterative_unbinding. Membership-mutating validators run during the analysis, predicates after — independent of the order listed.
gas = gethydro(getinfo(output, path))
cat = clumpfind(gas, ThresholdFoF(:rho; threshold=1e2, threshold_unit=:nH, linking_length=0.2))
# contrast-controlled watershed + tree-gravity boundedness with iterative unbinding:
cores = clumpfind(gas, DensityWatershed(:rho; threshold=1e2, threshold_unit=:nH,
                                        linking_length=0.4, persistence=0.3);
                  boundedness=true, egrav=:tree, iterative_unbinding=true)
# the same, written as a validator chain, plus virial + size cuts:
cores = clumpfind(gas, DensityWatershed(:rho; threshold=1e2, threshold_unit=:nH, linking_length=0.4);
                  validators=[MinMembers(20), Bound(:tree; iterative=true), VirialBelow(2.0)])
Mera.clumpplotMethod
clumpplot(cat::ClumpCatalog; background=nothing, sizeby=:mass, colormap=:viridis,
          max_markersize=28, kwargs...) -> Makie.Figure

Plot a ClumpCatalog: each clump's centre of mass as a marker, sized by sizeby (:mass, :radius, or :n_members) and coloured by log₁₀ mass. Pass background = a projection result (e.g. the gas surface density) to overlay the clumps on it. Needs a Makie backend loaded (using CairoMakie).

cat = clumpfind(gas, :rho; threshold=1e2, threshold_unit=:nH, linking_length=0.5)
using CairoMakie
bg  = projection(gas, :sd, :Msol_pc2; center=[:bc])
fig = clumpplot(cat; background=bg)
Mera.clumptableMethod
clumptable(cat::ClumpCatalog) -> NamedTuple

A columnar view of the catalog: a NamedTuple of equal-length vectors — id, n_members, mass, com_x, com_y(, com_z), radius, and (when present) peak, the boundedness columns (e_kin, e_therm, e_grav, alpha_vir, bound), and per-component masses/counts (mass_gas, n_gas, …). Drop straight into DataFrame(clumptable(cat)) or CSV.write.

Mera.column_integralFunction
column_integral(dataobject, quantity[, unit]; binning=:exact, <view & range kwargs>)
    -> (map, quantity, unit, los, up, cam_right, center, pixsize, extent, boxlen, scale)

Line-of-sight column integral ∫ q dl of an arbitrary field q — the path-length-weighted sum along each sightline (not mass-weighted). This is the geometric primitive behind a true column density / optical-depth map: e.g. q=:rho gives the mass column (the same physical quantity as :sd, up to the code↔physical unit conversion of ρ and the path length), a constant opacity κ gives τ = κ·∫ρ dl, and q=:ne (with unit) the dispersion-measure-like ∫n dl.

It is exact when binning=:exact (the analytic chord length through each cube is integrated per pixel) and approximate for :overlap/:cic. Internally this is projection(dataobject, quantity; mode=:sum, weighting=:volume, binning=binning, …) divided by the pixel area, since the volume-weighted :sum deposits Σ q·(cube∩pixel-column volume).

.map holds ∫ q dl with the path length in code units (multiply by the appropriate dataobject.scale factor for a physical length, e.g. .map .* dataobject.scale.cm). The camera basis and extent travel with the result.

Mera.comMethod

Calculate the center-of-mass of any ContainMassDataSetType:

com(dataobject::ContainMassDataSetType; unit::Symbol=:standard, mask::MaskType=[false])

return Tuple{Float64, Float64, Float64,}

Arguments

Required:

  • dataobject: needs to be of type: "ContainMassDataSetType"

Optional Keywords:

  • unit: the unit of the result (can be used w/o keyword): :standard (code units), :Mpc, :kpc, :pc, :mpc, :ly, :au , :km, :cm (of typye Symbol) ..etc. ; see for defined length-scales viewfields(info.scale)
  • mask: needs to be of type MaskType which is a supertype of Array{Bool,1} or BitArray{1} with the length of the database (rows)
Mera.comMethod

Calculate the joint center-of-mass of any HydroPartType:

com(dataobject::Array{HydroPartType,1}, unit::Symbol; mask::MaskArrayAbstractType=[[false],[false]])

return Tuple{Float64, Float64, Float64,}

Arguments

Required:

  • dataobject: needs to be of type: "Array{HydroPartType,1}""

Optional Keywords:

  • unit: the unit of the result (can be used w/o keyword): :standard (code units), :Mpc, :kpc, :pc, :mpc, :ly, :au , :km, :cm (of typye Symbol) ..etc. ; see for defined length-scales viewfields(info.scale)
  • mask: needs to be of type MaskArrayAbstractType which contains two entries with supertype of Array{Bool,1} or BitArray{1} and the length of the database (rows)
Mera.comoving_to_proper_densityMethod
comoving_to_proper_density(info, density_comoving) -> Float64

Convert a comoving mass density to proper density (proper = comoving / aexp^3). Identity for non-cosmological runs.

Mera.comoving_to_proper_lengthMethod
comoving_to_proper_length(info, length_comoving) -> Float64

Convert a comoving length to the proper length at the snapshot's aexp (proper = comoving * aexp). Identity for non-cosmological runs.

Mera.complete_progress!Function

Send final completion notification for progress tracker

Parameters:

  • tracker: Progress tracker to complete
  • final_message: Optional final message
  • include_summary: Include full execution summary (default: true)

Examples:

tracker = create_progress_tracker(1000, task_name="Simulation")
# ... do work with update_progress! calls ...
complete_progress!(tracker, "All galaxies processed successfully!")
Mera.configure_adaptive_ioMethod
configure_adaptive_io(simulation_path::String, output_num::Int; verbose=true)

Automatically configure I/O settings based on simulation characteristics.

Mera.configure_mera_ioMethod
configure_mera_io(; buffer_size="auto", cache=true, large_buffers=true, show_config=true)

Manually configure Mera I/O settings with user-friendly parameters.

Arguments

  • buffer_size: Buffer size as string ("32KB", "64KB", "128KB", "256KB", "512KB") or "auto"
  • cache=true: Enable file metadata caching for faster repeat operations
  • large_buffers=true: Enable large buffer optimizations
  • show_config=true: Display the applied configuration

Examples

# Use 128KB buffer with caching
configure_mera_io(buffer_size="128KB")

# Disable caching
configure_mera_io(buffer_size="64KB", cache=false)

# Maximum performance for very large simulations
configure_mera_io(buffer_size="512KB", cache=true, large_buffers=true)

# Minimal settings for small simulations
configure_mera_io(buffer_size="32KB", large_buffers=false)

Buffer size recommendations

  • "32KB": Small simulations (< 50 CPU files)
  • "64KB": Medium simulations (50-200 CPU files) - Default
  • "128KB": Large simulations (200-500 CPU files)
  • "256KB": Very large simulations (500-1000 CPU files)
  • "512KB": Huge simulations (> 1000 CPU files)
Mera.construct_datatypeMethod

Create a New DataSetType from a Filtered Data Table

function construct_datatype(data::IndexedTables.AbstractIndexedTable, dataobject::HydroDataType)
return HydroDataType

function construct_datatype(data::IndexedTables.AbstractIndexedTable, dataobject::PartDataType)
return PartDataType

function construct_datatype(data::IndexedTables.AbstractIndexedTable, dataobject::ClumpDataType)
return ClumpDataType

function construct_datatype(data::IndexedTables.AbstractIndexedTable, dataobject::GravDataType)
return GravDataType

Example

# read simulation information
julia> info = getinfo(420)
julia> gas = gethydro(info)

# filter and create a new` data table
julia> density = 3. /gas.scale.Msol_pc3
julia> filtered_db = @filter gas.data :rho >= density

# construct a new HydroDataType
# (comparable to the object "gas" but only with filtered data)
julia> gas_new = construct_datatype(filtered_db, gas)
Mera.convert_single_file_safeMethod
convert_single_file_safe(old_path::String, new_path::String, file_index::Int, 
                        total_files::Int, safety_margin::Float64) -> Bool

Convert a single JLD2 file with comprehensive safety monitoring and error handling. This is the core conversion function called by each thread.

Safety Features

  1. Pre-conversion memory check
  2. Post-loading memory monitoring
  3. Automatic garbage collection on violations
  4. Specific error handling for different failure modes
  5. Immediate memory cleanup after conversion

Parameters

  • old_path: Full path to source file
  • new_path: Full path to destination file
  • file_index: Current file number (for progress reporting)
  • total_files: Total files being processed
  • safety_margin: Memory usage threshold for violation detection

Returns

  • true: Successful conversion
  • false: Conversion failed (error logged)

Memory Management Strategy

  • Check safety margin before loading (most memory-intensive operation)
  • Monitor again after loading to catch memory spikes
  • Force garbage collection and nullify data references
  • Brief pause after GC to allow memory recovery
Mera.cosmologyMethod
cosmology(info::InfoType) -> NamedTuple

Return the cosmological state of the snapshot as a NamedTuple. All quantities are derived from the stored info fields, so this works on freshly read simulations and on Mera files of any age.

Fields:

fieldmeaning
iscosmologicalBool, see iscosmological
redshiftz = 1/aexp - 1
aexpscale factor a of the snapshot
H0Hubble constant [km/s/Mpc]
omega_mmatter density parameter Ωm
omega_ldark-energy density parameter ΩΛ
omega_kcurvature density parameter Ωk
omega_bbaryon density parameter Ωb
hubble_time_GyrHubble time 1/H0 [Gyr]
age_Gyrage of the universe at this snapshot [Gyr]
lookback_Gyrlookback time from z=0 to this snapshot [Gyr]
rho_crit_cgscritical density 3H(z)²/8πG at this snapshot [g/cm³]

For a non-cosmological run iscosmological is false, redshift is 0, and the cosmology-derived times/densities are returned as NaN (the sentinel info values are not physical).

c = cosmology(getinfo(80, "…/yt_cosmo"))
c.redshift        # ≈ 0.143
c.age_Gyr         # ≈ 11.9
Mera.covering_gridFunction
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) -> CoveringGridResult

Resample AMR cell data (HydroDataType, GravDataType, or RtDataType) 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). Coarse leaves are replicated, fine leaves volume-averaged; output cells outside the data are NaN. Particles and clumps are not AMR cells and raise a MethodError (use projection for particles).

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.

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 array
Mera.covering_grid_memoryFunction
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) -> NamedTuple

Predict 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).

Mera.create_progress_trackerMethod

Progress tracking with automatic time-based notifications

Creates a progress tracker that automatically sends notifications at specified time intervals or progress milestones.

Parameters:

  • total_items: Total number of items to process
  • time_interval: Send notification every N seconds (default: 300 = 5 minutes)
  • progress_interval: Send notification every N% progress (default: 10%)
  • task_name: Name of the task for notifications
  • zulip_channel: Zulip channel (default: "progress")
  • zulip_topic: Zulip topic (default: "Task Progress")

Returns: ProgressTracker object with update!() method

Examples:

# Create progress tracker for 1000 items, notify every 5 minutes or 10% progress
tracker = create_progress_tracker(1000, task_name="Galaxy analysis")

for i in 1:1000
    # Do some work
    process_galaxy(i)
    
    # Update progress (automatically sends notifications at intervals)
    update_progress!(tracker, i)
end

# Final completion notification
complete_progress!(tracker)
Mera.create_ultrafast_tableFunction
create_ultrafast_table(vars_1D, pos_1D, cpus_1D, names_constr, nvarh_corr, nvarh_i_list, read_cpu, isamr, verbose=false, max_threads=Threads.nthreads())

Creates IndexedTable with controlled threading for optimal performance.

Threading Control:

  • Uses min(maxthreads, availablethreads, total_columns) for optimal load balancing
  • Prevents thread over-subscription for small datasets
  • Provides thread usage feedback when verbose=true
Mera.createpathMethod

```julia createpath(output::Real, path::String; namelist::String="")

return FileNamesType ```

Mera.createscales!Method

Create an object with predefined scale factors from code to pysical units

function createscales!(dataobject::InfoType)

return ScalesType003
Mera.dataoverviewMethod
dataoverview(dataobject::ClumpDataType)

Get the extrema (min/max) of each variable in the clump database. Returns an IndexedTable with extrema per variable.

Mera.dataoverviewMethod
dataoverview(dataobject::GravDataType; verbose::Bool=true)

Get total epot and min/max values of each gravity variable per level. Returns an IndexedTable summarizing epot and other variables.

Mera.dataoverviewMethod
dataoverview(dataobject::HydroDataType; verbose::Bool=true)

Provide a comprehensive overview of hydro simulation data including variable statistics.

Arguments

  • dataobject::HydroDataType: Hydro simulation data object
  • verbose::Bool=true: Control level of output detail

Returns

  • IndexedTable: Mass and min/max values for each variable per refinement level

Description

Analyzes hydro data and provides statistics across AMR levels.

Mera.dataoverviewMethod
dataoverview(dataobject::PartDataType; verbose::Bool=true)

Get the min/max value of each particle variable per AMR level. Returns an IndexedTable summarizing min/max per level.

Mera.delete_fieldMethod
delete_field(name::Symbol; datatypes=:all)

Remove a previously add_field-registered field. datatypes=:all (default) removes it from every kind; otherwise pass a kind symbol or collection.

Mera.depletion_timeMethod
depletion_time(dataobject, sfr_Msol_yr; mass=:mass, mask=[false]) -> NamedTuple

Gas depletion time and star-formation efficiency per free-fall time. Given a gas region and its star-formation rate sfr_Msol_yr [M⊙/yr], returns

  • t_depl_Gyr = M_gas / SFR — how long the present SFR would take to consume the gas;
  • t_ff_mw_Myr — the mass-weighted mean free-fall time ⟨√(3π/32Gρ)⟩ (per-cell :freefall_time);
  • eps_ff = SFR · ⟨t_ff⟩ / M_gas — the dimensionless star-formation efficiency per free-fall time (Krumholz–McKee), typically ~0.01–0.1;
  • M_gas_Msol, sfr.

Use a mask (e.g. dense star-forming gas getvar(gas,:rho,:nH) .> 27) to measure the efficiency of the gas actually forming stars. Works on any grid data with :mass and :freefall_time.

_, s = sfr_snapshot(stars).sfr[2], 0   # or any SFR estimate in M⊙/yr
d = depletion_time(gas, 1.5; mask = getvar(gas,:rho,:nH) .> 27)
d.t_depl_Gyr, d.eps_ff
Mera.downsampleMethod
downsample(plan::ReportPlan, target_s) -> ReportPlan

Return a new plan trimmed to an estimated wall-time of target_s seconds: first drop the read level (fewest cells — helps every card), then shrink projection resolution and histogram bins. Used by report(...; budget_s=target_s). Never goes below levelmin / minimum sane resolution.

Mera.dust_opacityMethod
dust_opacity(wavelength_um; kappa_V=210.0, Z_over_Zsun=1.0, beta=1.8) -> Float64

Approximate dust opacity per gram of gas κ(λ) [cm²/g] for a Milky-Way (RV≈3.1) extinction curve, for use as the kappa of [`absorptionmap](@ref). ReturnsκV · (Aλ/AV) · ZoverZsun, whereAλ/A_Vis interpolated (log–log) from a representative MW curve for0.15 ≤ λ ≤ 2.2 μmand extended into the IR as aλ^{-beta}` power law beyond 2.2 μm.

  • kappa_V — V-band opacity per gram of gas (default 210 cm²/g, i.e. A_V/N_H≈5.3e-22 mag cm² with μ≈1.4); this is why the old grey default κ≈200 was "dust-like".
  • Z_over_Zsun — linear metallicity (dust-to-gas) scaling of the dust opacity.
  • beta — IR emissivity index for the λ > 2.2 μm extrapolation.
κ = dust_opacity(0.55)              # V band ≈ 210 cm²/g
κ = dust_opacity(0.15; Z_over_Zsun=0.3)   # FUV, metal-poor
a = absorption_map(gas; kappa=κ)   # grey at that wavelength
Approximate

A single MW curve scaled by metallicity — adequate for mock extinction/silhouette images, not a substitute for a dust radiative-transfer code. For a precise band pass your own κ.

Mera.edge_onMethod
edge_on(data; center=:com, aperture=nothing, range_unit=:standard)

Return a GalaxyFrame oriented edge-on: the line of sight lies in the disk plane (perpendicular to the spin axis) and the spin axis points up in the image. Same arguments as face_on.

Mera.emission_mapMethod
emission_map(dataobject; kappa, source, <view & range kwargs>, res=256, pxsize=nothing)
    -> (map, tau, x, y, extent, los, up, cam_right, center, pixsize, scale)

Off-axis emission + absorption map: the front-to-back formal solution of radiative transfer along each sightline, I = Σ_cells S·(1 − e^{−Δτ})·e^{−τ_front} with Δτ = κ·ℓ and the exact box-spline chord length per cell (the geometry the :exact deposit already computes). This turns the conservative projection into an approximate radiative-transfer mock observation (emission attenuated by intervening optical depth).

  • kappa — absorption coefficient (per code length): a getvar field name (Symbol), a constant (Real), or a per-cell vector. The emissivity is κ·S, so a small but nonzero κ gives the optically-thin limit I ≈ S·κL, while kappa=0 yields zero emission. For a κ-independent optically-thin column use column_integral or mode=:sum.
  • source — source function / emissivity S: a field name, constant, or per-cell vector.

Cells are accumulated nearest→farthest from the observer (the observer is on the −ŵ side; ŵ points away from the observer). Returns .map = observed intensity I and .tau = total optical depth, plus the camera metadata. Validation: a uniform slab of depth L with constant κ,S gives I = S(1 − e^{−κL}) (thin limit S·κL, thick limit S). View/centring keywords are the same as projection.

Mera.ensure_optimal_io!Method
ensure_optimal_io!(info::InfoType; force_reoptimize=false, verbose=false)

Automatically ensures optimal I/O settings based on simulation characteristics. This function is called transparently by gethydro(), getparticles(), and getgravity().

Arguments

  • info: InfoType object from getinfo()
  • force_reoptimize=false: Force re-optimization even if already optimized
  • verbose=false: Enable detailed output (usually disabled for transparent operation)

Returns

  • true if optimization was applied/verified, false if failed
Mera.estimateMethod
estimate(plan::ReportPlan) -> NamedTuple

Zero-I/O runtime estimate for a [ReportPlan]: returns (per_card, read_s, compute_s, total_s, level, cells, sampled, calibrated) where per_card is a vector of (label, kind, datatype, cells, seconds). Absolute times are advisory until the cost model is calibrate!d (calibrated=false ⇒ treat as ±2×).

Mera.export_vtkMethod

Export particle data to VTK format for visualization in tools like ParaView.

  • export data that is present in your database and can be processed by getvar() (done internally)
  • select scalar(s) and their unit(s)
  • select a vector and its unit (like velocity)
  • export data in log10
  • creates binary files with optional compression
  • supports multi-threading

-> generates VTU files; each particle is represented as a vertex point with associated scalar and vector data.

export_vtk(
    dataobject::PartDataType, outprefix::String;
    scalars::Vector{Symbol} = [:mass],
    scalars_unit::Vector{Symbol} = [:Msol],
    scalars_log10::Bool=false,
    vector::Array{<:Any,1}=[missing, missing, missing],
    vector_unit::Symbol = :km_s,
    vector_name::String = "velocity",
    vector_log10::Bool=false,
    positions_unit::Symbol = :standard,
    chunk_size::Int = 50000,
    compress::Bool = false,
    max_particles::Int = 100_000_000,
    verbose::Bool = true,
    myargs::ArgumentsType=ArgumentsType()
)

Arguments

Required:

  • **dataobject::PartDataType:*** needs to be of type "PartDataType"
  • outprefix: The base path and prefix for output file (e.g., "foldername/particles" will create "foldername/particles.vtu").

Predefined/Optional Keywords:

  • scalars: List of scalar variables to export (default is particle mass); from the database or a predefined quantity (see field: info, function getvar(), dataobject.data)
  • scalars_unit: Sets the unit for the list of scalars (default is :Msol).
  • scalars_log10: Apply log10 to the scalars (default false).
  • vector: List of vector component variables to export (default is missing).
  • vector_unit: Sets the unit for the vector components (default is km/s).
  • vector_name: The name of the vector field in the VTK file (default: "velocity").
  • vector_log10: Apply log10 to the vector components (default: false).
  • positions_unit: Sets the unit of the particle positions (default: code units); usefull in paraview to select regions
  • chunk_size::Int = 50000: Size of data chunks for processing (reserved for future optimizations).
  • compress: If false (default), disable compression.
  • max_particles: Maximum number of particles to export (caps output if exceeded), (default: 100000000)
  • verbose: If true (default), print detailed progress and diagnostic messages.
Mera.extract_column_dataMethod
extract_column_data(vars_1D, pos_1D, cpus_1D, nvarh_corr, nvarh_i_list, col_idx, read_cpu, isamr)

Helper function to extract data for a specific column index. Centralizes the column extraction logic for better maintainability.

Mera.face_onMethod
face_on(data; center=:com, aperture=nothing, range_unit=:standard)

Return a GalaxyFrame oriented face-on: the line of sight is the object's angular-momentum (spin) axis, so a projection with los=fr.los sees the disk from above.

  • center:com (default), :densest, or an explicit [x,y,z] in range_unit.
  • aperture — optional sphere radius (in range_unit) around the centre; measure the spin only from gas inside it, to isolate the disk from the halo/outskirts.
fr = face_on(gas)                         # whole object, centred on the CoM
fr = face_on(gas; aperture=10, range_unit=:kpc)   # spin from the inner 10 kpc
projection(gas, :sd; los=fr.los, up=fr.up, center=fr.center, range_unit=fr.center_unit)
Several objects, mergers, cosmological boxes

The bare call assumes one object: it uses the global CoM and the summed angular momentum, which are meaningless when the box holds many galaxies (the CoM lands between them and unrelated spins cancel). Point it at the object instead — give a seed center (a known/halo position, or :densest for the densest peak) and an aperture; the frame then re-centres on the local CoM inside that sphere and measures only that object's spin:

fr = face_on(gas; center=:densest, aperture=30, range_unit=:kpc)   # the densest galaxy
fr = face_on(gas; center=[x,y,z],  aperture=30, range_unit=:kpc)   # a catalogued halo

Equivalently, subregion the object out first and call face_on on that. Measuring about the local CoM also removes the object's bulk motion and the Hubble flow, so this is the correct recipe in cosmological runs and during mergers.

Mera.field_dependenciesMethod
field_dependencies(kind::Symbol, var::Symbol) -> (; direct, raw)

Inspect a derived field's dependencies for data-type kind: direct are its immediate dependencies (raw or derived, as declared), raw is the transitive set of physical stored variables it ultimately needs (same as getvar_requirements). Works for built-in and add_field-registered quantities.

Mera.field_infoMethod
field_info(name::Symbol; kind::Symbol=:hydro)

The registration record (; compute, depends_on, unit, description) for a user field, or nothing if it isn't registered for that kind.

Mera.field_treeMethod
field_tree(kind::Symbol, var::Symbol; io=stdout)

Pretty-print the dependency tree of a derived field down to its raw leaves (cycle-safe).

Mera.filter_by_rangeMethod
filter_by_range(files::Vector{String}, start_num::Int, end_num::Int) -> Vector{String}

Filter and sort files by output number range. Only files matching the RAMSES pattern and within the specified range are included.

Algorithm

  1. Parse output number from each filename
  2. Keep only files with valid numbers within [startnum, endnum]
  3. Sort numerically (not lexicographically) for consistent processing order

Why Sorting Matters

  • Ensures predictable processing order
  • Makes progress tracking more intuitive
  • Helps with debugging and result verification
  • Important for time-series data analysis workflows
Mera.filterdataMethod
filterdata(obj, condition...; verbose=true) -> same-type Mera object
filterdata(obj, quantity, predicate; unit=:standard, verbose=true) -> same-type Mera object

Select the rows of obj (hydro / gravity / RT / particles / clumps) matching a value-space condition and return a new object of the same type — chainable with projection, getvar, subregion, … . Conditions select by any getvar quantity in any unit and compose with &/|/!; several positional conditions are AND-combined. The quantity/ predicate form is a shorthand for a single condition.

hot   = filterdata(gas, Above(:T, 1e4; unit=:K))
cold_dense = filterdata(gas, Below(:T, 1e3; unit=:K) & Above(:rho, 100; unit=:nH))
disc  = filterdata(gas, InRange(:r_cylinder, 0, 15; unit=:kpc), Below(:vz, 50; unit=:km_s))
projection(hot, :sd, :Msol_pc2)        # the result is a normal Mera object
Mera.fluxbudgetMethod
fluxbudget(obj::HydroDataType; surface=:sphere, radius, shell_width,
           quantities=[:mass], center=[:bc], range_unit=:kpc,
           phases=nothing, verbose=true) -> FluxBudgetType

Flux through a surface, split into inflow / outflow. surface is :sphere (radius radius) or :cylinder (curved wall at cylindrical radius radius); the thin shell has width shell_width (both in range_unit) centred at center. quantities[:mass, :momentum, :energy, :metals].

Returns a FluxBudgetType: per quantity an (in, out, net, unit) rate — mass & metals in Msol/yr, momentum in Msol·km/s/yr, energy in erg/s. in sums the cells moving inward (v⊥ < 0) and out those moving outward (v⊥ ≥ 0); net = in + out. For mass/metals/energy in ≤ 0 and out ≥ 0; for momentum the carried quantity already contains v⊥ (radial momentum m·v⊥), so both in and out are ≥ 0 — the ram-pressure flux from in- and out-moving gas respectively. Pass phases = (cold = o->getvar(o,:T,:K).<1e4, hot = o->getvar(o,:T,:K).>=1e4) (a NamedTuple of shell→mask functions) for a per-phase breakdown in .components (the phases sum to the total).

gas = gethydro(getinfo(output, path))
fb  = fluxbudget(gas; surface=:sphere, radius=30.0, shell_width=2.0, range_unit=:kpc,
                 quantities=[:mass, :energy])
fb.rates.mass.out        # outflow rate, Msol/yr
fb.rates.mass.net        # net (in + out)
Mera.fluxmapMethod
fluxmap(obj::HydroDataType; surface=:sphere, radius, shell_width, quantity=:vr,
        nbins=(72, 36), center=[:bc], range_unit=:kpc, verbose=true) -> FluxMapType

A surface map of the flux through the shell — where gas flows in vs out — binned by surface coordinates: (φ, cosθ) for a :sphere (equal-solid-angle sky map), (φ, z) for a :cylinder (the wall unrolled). This is not projection: projection integrates along a Cartesian axis and superposes the near and far side of the shell; fluxmap places each cell at its own surface location.

quantity=:vr (default) maps the mass-weighted mean normal velocity (km/s; inflow < 0, outflow > 0) — the clearest "where is the inflow/outflow" picture. quantity=:mdot maps the per-bin mass-flux contribution (Msol/yr), whose sum equals the net mass flux. nbins=(nφ, nθ_or_z).

fm = fluxmap(gas; surface=:sphere, radius=30.0, shell_width=2.0, range_unit=:kpc, quantity=:vr)
fm.map           # nφ × ncosθ map of mean v⊥ [km/s] — heatmap it (red out, blue in)
fm.xedges, fm.yedges
Mera.fluxmapplotMethod
fluxmapplot(fm::FluxMapType; kwargs...) -> Makie.Figure

Render a fluxmap surface map as a heatmap — a perceptually-uniform diverging colormap (:vik) centred at zero for :vr (blue inflow / red-brown outflow), perceptually-uniform sequential (:viridis) for :mdot. Both are colorblind-safe. For :vr the symmetric range is clipped at the clip percentile of |v⊥| (default 0.95) so a few extreme cells don't wash out the contrast. Pass colormap= / clip= to override. Needs a Makie backend (using CairoMakie).

using CairoMakie
fm = fluxmap(gas; surface=:sphere, radius=30.0, shell_width=2.0, range_unit=:kpc)
fig = fluxmapplot(fm); Makie.save("flux_skymap.png", fig)
Mera.fluxprofileMethod
fluxprofile(obj::HydroDataType; surface=:sphere, radii, shell_width, quantity=:mass,
            center=[:bc], range_unit=:kpc, verbose=true) -> NamedTuple

Radial flux profile: run fluxbudget for quantity at each radius in radii (a vector or range, in range_unit) and assemble the inflow / outflow / net rate — with its sampling uncertainty — versus radius. Shows where the flux is launched or converges and lets you pick a converged radius and shell width. shell_width is the (constant) Δr of every shell.

Returns (; radius, in, out, net, err_net, n_cells, unit, surface, shell_width, quantity).

fp = fluxprofile(gas; surface=:sphere, radii=5:5:50, shell_width=2.0, range_unit=:kpc)
fp.radius, fp.net, fp.err_net      # net Ṁ(R) ± sampling error [Msol/yr]
Mera.fluxshellMethod
fluxshell(obj::HydroDataType; surface=:sphere, radius, shell_width, center=[:bc], range_unit=:kpc)
    -> HydroDataType

Return the exact thin shell that fluxbudget measures — the AMR cells in [radius-shell_width/2, radius+shell_width/2] (spherical, or a cylindrical annulus) — as a normal HydroDataType. Use it to visualize what was measured: project it, profile it, or map the surface-normal velocity to see where gas flows in vs out.

sh = fluxshell(gas; surface=:sphere, radius=30.0, shell_width=2.0, range_unit=:kpc)
projection(sh, :sd, :Msol_pc2; center=[:bc])              # the shell as a ring/annulus
projection(sh, :vr_sphere, :km_s; center=[:bc])           # inflow (<0) / outflow (>0) over the shell
Mera.fluxtimeseriesFunction
fluxtimeseries(loadfn, outputs, surface=:sphere; radius, shell_width, quantity=:mass,
               time_unit=:Myr, kwargs...) -> NamedTuple

Evolution of the flux through a fixed surface across a snapshot series. loadfn(output) returns a loaded HydroDataType (e.g. o -> gethydro(getinfo(o, path), verbose=false)); outputs is the list of output numbers. For each snapshot it runs fluxbudget for quantity and assembles the inflow / outflow / net rate versus time. Extra kwargs (shell_width, center, range_unit, …) pass through to fluxbudget.

fts = fluxtimeseries(o -> gethydro(getinfo(o, "/sim"), verbose=false), 100:10:300, :sphere;
                     radius=30.0, shell_width=2.0)
fts.t, fts.out          # time [Myr], outflow rate [Msol/yr]
Mera.fmt_timeMethod

Pretty-print duration in seconds as h/m/s.

Mera.formation_redshiftMethod
formation_redshift(info::InfoType, birth)

Redshift z_form = 1/a_birth − 1 at which each star particle formed, for a cosmological RAMSES run, from its super-conformal :birth time(s) (scalar or array). Non-star sentinels (birth = 0) and birth times after the snapshot return NaN, so filter with birth .< 0 (or isfinite). See also formation_time.

(Note: via getvar(particles, :zform) these NaNs become 0 — getvar maps all NaNs to 0 — so there too, select stars with birth .< 0.)

zf = formation_redshift(info, getvar(part, :birth))
Mera.formation_timeMethod
formation_time(info::InfoType, birth; unit::Symbol=:Gyr)

Cosmic time (age of the universe) at which each star particle formed, for a cosmological RAMSES run, from its super-conformal :birth time(s). unit: :Gyr (default), :Myr, :yr, :s. Non-star sentinels return NaN. Equivalently formation_time = age_of_universe(snapshot) − stellar_age.

Mera.get_available_memory_gbMethod
get_available_memory_gb() -> Float64

Get currently available (free) system memory in GB. Uses Sys.free_memory() which returns bytes, converts to GB for readability.

Mera.get_cylinder_inclusion_weightMethod
get_cylinder_inclusion_weight(cx, cy, cz, level, cx_shift, cy_shift, cz_shift, 
                             radius_shift, height_shift, cell, smooth_boundary, boundary_width)

Calculate inclusion weight for a cell in cylindrical subregion with optional smooth boundaries.

Returns

  • Float64: Weight between 0.0 (excluded) and 1.0 (fully included)
Mera.get_disk_info_commandMethod

Get cross-platform disk information command string

Returns the appropriate command string for getting disk usage information based on the current operating system.

Usage Example (use carefully - exposes disk info):

julia> cmd = get_disk_info_command()  # Get command string
julia> notifyme(msg="Disk status:", capture_output=cmd)  # Use only when necessary
Mera.get_filtered_rangesMethod
get_filtered_ranges(gravitydata::GravDataType)

Extract spatial ranges from a GravDataType for use with projection functions.

Returns the ranges in the format expected by projection functions: (xrange, yrange, zrange) as arrays of [min, max] values.

Arguments

  • gravitydata::GravDataType: Data object containing filtered spatial ranges

Returns

  • Tuple{Array,Array,Array}: (xrange, yrange, zrange) for projection functions

Example

gravity_subregion = subregioncuboid(gravity, xrange=[0.4, 0.6], yrange=[0.4, 0.6])
xr, yr, zr = get_filtered_ranges(gravity_subregion)
projection(gravity_subregion, vars; xrange=xr, yrange=yr, zrange=zr, ...)
Mera.get_filtered_rangesMethod
get_filtered_ranges(hydrodata::HydroDataType)

Extract spatial ranges from a HydroDataType for use with projection functions.

Returns the ranges in the format expected by projection functions: (xrange, yrange, zrange) as arrays of [min, max] values.

Arguments

  • hydrodata::HydroDataType: Data object containing filtered spatial ranges

Returns

  • Tuple{Array,Array,Array}: (xrange, yrange, zrange) for projection functions

Example

gas_subregion = subregioncuboid(gas, xrange=[0.4, 0.6], yrange=[0.4, 0.6])
xr, yr, zr = get_filtered_ranges(gas_subregion)
projection(gas_subregion, vars; xrange=xr, yrange=yr, zrange=zr, ...)
Mera.get_filtered_rangesMethod
get_filtered_ranges(rtdata::RtDataType)

Extract spatial ranges from a RtDataType for use with projection functions.

Returns the ranges in the format expected by projection functions: (xrange, yrange, zrange) as arrays of [min, max] values.

Arguments

  • rtdata::RtDataType: Data object containing filtered spatial ranges

Returns

  • Tuple{Array,Array,Array}: (xrange, yrange, zrange) for projection functions

Example

rt_subregion = subregioncuboid(rt, xrange=[0.4, 0.6], yrange=[0.4, 0.6])
xr, yr, zr = get_filtered_ranges(rt_subregion)
projection(rt_subregion, vars; xrange=xr, yrange=yr, zrange=zr, ...)
Mera.get_height_cylinderMethod
get_height_cylinder(cz, level, cz_shift, cell)

Calculate distance from cell to cylinder center plane for cylindrical subregion selection.

This function handles both cell-based and point-based selection modes:

  • Cell-based (cell=true): Returns minimum distance from cell boundary to center plane
  • Point-based (cell=false): Returns distance from cell center to center plane

Arguments

  • cz: Cell z-coordinate in grid units
  • level: AMR level of the cell
  • cz_shift: Cylinder center plane position in physical coordinates [0,1]
  • cell::Bool: Selection mode (true=cell-based, false=point-based)

Returns

  • Float64: Distance from cell to cylinder center plane in physical coordinates

Algorithm

For cell-based selection, returns 0 if the center plane intersects the cell, otherwise returns distance to closest cell boundary. For point-based selection, returns absolute distance from cell center to center plane.

Mera.get_memory_info_commandMethod

Get cross-platform memory information command string

Returns the appropriate command string for getting detailed memory information based on the current operating system.

Usage Example (use carefully - exposes system info):

julia> cmd = get_memory_info_command()  # Get command string only
julia> notifyme(msg="Memory status:", capture_output=cmd)  # Use judiciously

Platform-specific commands:

  • macOS: vmstat + memorypressure (native Darwin tools)
  • Linux: free + /proc/meminfo (standard Linux memory tools)
  • Windows: wmic memory queries (Windows Management Interface)
Mera.get_memory_usage_percentageMethod
get_memory_usage_percentage() -> Float64

Calculate current memory usage as percentage of total system memory. Formula: (totalmemory - availablememory) / total_memory * 100 This gives the percentage of memory currently in use by all system processes.

Mera.get_network_info_commandMethod

Get cross-platform network information command string

Returns the appropriate command string for getting network configuration based on the current operating system.

Usage Example (use carefully - exposes network info):

julia> cmd = get_network_info_command()  # Get command string
julia> notifyme(msg="Network status:", capture_output=cmd)  # Consider privacy implications
Mera.get_process_info_commandMethod

Get cross-platform process information command string

Returns the appropriate command string for getting running process information based on the current operating system.

Usage Example (use carefully - exposes process info):

julia> cmd = get_process_info_command()  # Get command string
julia> notifyme(msg="Process status:", capture_output=cmd)  # Use only when necessary
Mera.get_radius_cylinderMethod
get_radius_cylinder(cx, cy, level, cx_shift, cy_shift, cell)

Calculate distance from cell to cylinder axis for cylindrical subregion selection.

This function handles both cell-based and point-based selection modes:

  • Cell-based (cell=true): Returns minimum distance from cell boundary to cylinder axis
  • Point-based (cell=false): Returns distance from cell center to cylinder axis

Arguments

  • cx, cy: Cell coordinates in grid units
  • level: AMR level of the cell
  • cx_shift, cy_shift: Cylinder axis position in physical coordinates [0,1]
  • cell::Bool: Selection mode (true=cell-based, false=point-based)

Returns

  • Float64: Distance from cell to cylinder axis in physical coordinates

Algorithm

For cell-based selection, finds the closest point on the cell boundary to the axis using clamp operations. For point-based selection, uses cell center.

Mera.get_radius_sphereMethod
get_radius_sphere(cx, cy, cz, level, cx_shift, cy_shift, cz_shift, cell)

Calculate distance from cell to sphere center for spherical subregion selection.

This function handles both cell-based and point-based selection modes:

  • Cell-based (cell=true): Returns minimum distance from cell boundary to sphere center
  • Point-based (cell=false): Returns distance from cell center to sphere center

Arguments

  • cx, cy, cz: Cell coordinates in grid units
  • level: AMR level of the cell
  • cx_shift, cy_shift, cz_shift: Sphere center position in physical coordinates [0,1]
  • cell::Bool: Selection mode (true=cell-based, false=point-based)

Returns

  • Float64: Distance from cell to sphere center in physical coordinates

Algorithm

For cell-based selection, finds the closest point on the cell boundary to the center using clamp operations on each dimension. For point-based selection, uses the Euclidean distance from cell center to sphere center.

Example

# Distance from cell at (10,20,30) on level 2 to sphere at (0.5,0.5,0.5)
distance = get_radius_sphere(10, 20, 30, 2, 0.5, 0.5, 0.5, true)
Mera.get_simulation_characteristicsMethod
get_simulation_characteristics(simulation_path::String, output_num::Int)

Analyze simulation folder to determine optimal I/O settings. Returns a dictionary with simulation characteristics and recommended settings.

Mera.get_system_info_commandMethod

Get cross-platform system information command string

Returns the appropriate command string for getting system information (memory, disk, CPU) based on the current operating system.

Usage Examples (use carefully - exposes system info):

julia> cmd = get_system_info_command()  # Get command string
julia> notifyme(msg="System status:", capture_output=cmd)  # Consider privacy implications
julia> cmd = get_memory_info_command()  
julia> notifyme(msg="Memory status:", capture_output=cmd)

Cross-platform compatibility:

  • macOS: Uses vmstat, memorypressure, df, sysctl
  • Linux: Uses free, df, /proc/meminfo, /proc/cpuinfo
  • Windows: Uses wmic, systeminfo commands
Mera.get_total_memory_gbMethod
get_total_memory_gb() -> Float64

Get total installed system memory in GB. Uses Sys.total_memory() for accurate system capacity measurement.

Mera.get_unit_factor_fastMethod

Generate optimized unit conversion at compile time. Eliminates runtime unit lookup overhead.

Mera.getclumpsMethod

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::Array{<:Any,1}=[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 argument range_unit and relative to the given center; zero length for xmin=xmax=0. is converted to maximum possible length
  • yrange: the range between [ymin, ymax] in units given by argument range_unit and relative to the given center; zero length for ymin=ymax=0. is converted to maximum possible length
  • zrange: the range between [zmin, zmax] in units given by argument range_unit and relative to the given center; zero length for zmin=zmax=0. is converted to maximum possible length
  • zrange: the range between [zmin, zmax] in units given by argument range_unit and relative to the given center; 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 in vars (or use vars=[: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 argument range_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 CPU
  • verbose: print timestamp, selected vars and ranges on screen; default: true
  • myargs: 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 Float64 from 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-") and Symbol("rho+").
  • For faster I/O, pass a smaller vars list to read only the columns you need.
  • When supplying a custom vars list, 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.getextentMethod

Get the extent of the dataset-domain:

function getextent( dataobject::DataSetType;
                     unit::Symbol=:standard,
                     center::Array{<:Any,1}=[0., 0., 0.],
                     center_unit::Symbol=:standard,
                     direction::Symbol=:z)

return (xmin, xmax), (ymin ,ymax ), (zmin ,zmax )

Arguments

Required:

  • dataobject: needs to be of type: "DataSetType"

Predefined/Optional Keywords:

  • center: in unit given by argument center_unit; by default [0., 0., 0.]; the box-center can be selected by e.g. [:bc], [:boxcenter], [value, :bc, :bc], etc..
  • center_unit: :standard (code units), :Mpc, :kpc, :pc, :mpc, :ly, :au , :km, :cm (of typye Symbol) ..etc. ; see for defined length-scales viewfields(info.scale)
  • direction: todo
  • unit: return the variables in given unit

Defined Methods - function defined for different arguments

  • getextent( dataobject::DataSetType; # one given variable
  • getextent( dataobject::DataSetType, unit::Symbol; ...) # one given variable with its unit
Mera.getgravityMethod

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::Array{<:Any,1}=[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.gethydroMethod
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.

Mera.gethydroMethod

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::Array{<:Any,1}=[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 data
  • var(s): the selected hydro variables in arbitrary order: :all (default), :cpu, :rho, :vx, :vy, :vz, :p, and the passive scalars. When the output has a hydro_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 argument range_unit and relative to the given center; zero length for xmin=xmax=0. is converted to maximum possible length
  • yrange: the range between [ymin, ymax] in units given by argument range_unit and relative to the given center; zero length for ymin=ymax=0. is converted to maximum possible length
  • zrange: the range between [zmin, zmax] in units given by argument range_unit and relative to the given center; zero length for zmin=zmax=0. is converted to maximum possible length
  • range_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 argument range_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 inactive
  • smallc: set lower limit for thermal pressure; zero means inactive
  • check_negvalues: check loaded data of "rho" and "p" on negative values; false by default
  • print_filenames: print on screen the current processed hydro file of each CPU
  • verbose: print timestamp, selected vars and ranges on screen; default: true
  • show_progress: print progress bar on screen
  • myargs: 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.gethydro_athenaMethod
gethydro_athena(info::InfoType; xrange, yrange, zrange, center, range_unit, verbose=true) -> HydroDataType

Read an Athena++ HDF5 snapshot described by info (from getinfo_athena) into a HydroDataType with columns (:level, :cx, :cy, :cz, <vars…>) in Mera's AMR convention, so the analysis layer works on it unchanged. Each MeshBlock's cells are placed on the level lattice via its LogicalLocation and level.

xrange/yrange/zrange (+ center, range_unit) select a spatial window at load time (the leaf-cell analogue of Athena++'s own athdf(x1_min=…, x1_max=…)), exactly as for the RAMSES gethydro; the returned object's ranges records it.

Mera.gethydro_flashMethod
gethydro_flash(info::InfoType; xrange, yrange, zrange, center, range_unit, verbose=true) -> HydroDataType

Read a FLASH HDF5 snapshot described by info (from getinfo_flash) into a HydroDataType with columns (:level, :cx, :cy, :cz, <vars…>) in Mera's AMR convention. Only leaf blocks (node type == 1) are loaded. xrange/yrange/zrange (+ center, range_unit) select a spatial window at load time, reading only the intersecting leaf blocks (per-block HDF5 hyperslabs), exactly as for the RAMSES gethydro.

Mera.gethydro_plutoMethod
gethydro_pluto(info::InfoType; xrange, yrange, zrange, center, range_unit, verbose=true) -> HydroDataType

Read a PLUTO static-grid snapshot (data.NNNN.dbl, single-file double precision) described by info (from getinfo_pluto) into a uniform-grid HydroDataType — columns (:cx,:cy,:cz, :rho,:vx,:vy,:vz,:p), the same schema the RAMSES uniform-grid reader produces, so the whole analysis layer works on it unchanged.

xrange/yrange/zrange (+ center, range_unit) select a spatial window at load time, exactly as for the RAMSES gethydro; the returned object's ranges records it.

Mera.getinfoFunction
getinfo([output::Real]; path::String="", namelist::String="", verbose::Bool=true)

Return simulation overview metadata (an InfoType) for a RAMSES output. It inspects info, descriptor and header files (hydro / gravity / particles / RT / clumps), parses the namelist when available, gathers compile + build information, and collects basic cosmological units & scaling factors.

Call patterns: info = getinfo(42) # current directory, output 42 info = getinfo(output=42, path="/sim") # explicit keywords info = getinfo("/sim"; output=42) # path first

Set verbose=false to suppress the textual summary. The returned object exposes fields like descriptor, grid_info, part_info, scale, and helper accessors (namelist(info), makefile(info), timerfile(info), etc.).

Mera.getinfo_athenaMethod
getinfo_athena(output::Int, path::String; unit_length=1.0, unit_density=1.0,
               unit_velocity=1.0, verbose=true) -> InfoType

Read Athena++ HDF5 (.athdf) snapshot metadata for output in path (a directory holding the …NNNNN.athdf file, or the file itself) into a Mera InfoType (simcode = "Athena++"). The AMR level range maps to levelmin/levelmax (levelmin == levelmax ⇒ uniform grid). Feed the result to gethydro.

Units. Athena++ data is in code units; supply the run's CGS unit_length/unit_density/ unit_velocity for physical :kpc/:Msol/… conversions (defaults treat the run as dimensionless, see getinfo_pluto for the same convention).

Mera.getinfo_flashMethod
getinfo_flash(output::Int, path::String; unit_length=1.0, unit_density=1.0,
              unit_velocity=1.0, verbose=true) -> InfoType

Read FLASH HDF5 snapshot metadata for output in path (a directory holding the …_hdf5_plt_cnt_NNNN / …_hdf5_chk_NNNN file, or the file itself) into a Mera InfoType (simcode = "FLASH"). The PARAMESH refinement range maps to levelmin/levelmax. Feed the result to gethydro.

Units. FLASH usually writes CGS, so the defaults (unit_* = 1) treat code units as CGS and :kpc/:Msol/… conversions are already physical. Override unit_length/unit_density/ unit_velocity for a run in scaled units (same convention as getinfo_athena).

Mera.getinfo_gadgetMethod
getinfo_gadget(output::Int, path::String; unit_length=1.0, unit_density=1.0,
               unit_velocity=1.0, verbose=true) -> InfoType

Read GADGET HDF5 snapshot metadata for output in path (a directory holding the snap…_NNN.hdf5 file, or the file itself) into a Mera InfoType (simcode = "GADGET"). GADGET is particle-based; feed the result to getparticles.

Units. GADGET data is in code units (commonly length kpc/h, mass 10¹⁰ M⊙/h, velocity km/s); the defaults treat the run as dimensionless. Supply the run's CGS unit_length/unit_density/ unit_velocity (and note the h factors) for physical conversions.

Mera.getinfo_plutoMethod
getinfo_pluto(output::Int, path::String; unit_length=1.0, unit_density=1.0,
              unit_velocity=1.0, verbose=true) -> InfoType

Read PLUTO static-grid metadata (grid.out + dbl.out) for snapshot output in path into a Mera InfoType (simcode = "PLUTO"). Uniform 3-D Cartesian grid → levelmin == levelmax. Feed the result to gethydro.

Units. PLUTO writes data in code units and does not store its UNIT_* constants in the output, so by default the run is treated as dimensionless (unit_* = 1) — Mera's scale system still works, but physical conversions like :kpc/:Msol are only meaningful if you supply the run's CGS units. Pass PLUTO's UNIT_LENGTH, UNIT_DENSITY, UNIT_VELOCITY (the unit_length/unit_density/unit_velocity keywords, in CGS) for a dimensional run and every getvar/projection unit conversion becomes physical:

# a galactic PLUTO run, say UNIT_LENGTH = 1 kpc, UNIT_DENSITY = m_p, UNIT_VELOCITY = 1 km/s
info = getinfo_pluto(5, path; unit_length=3.086e21, unit_density=1.67e-24, unit_velocity=1e5)
getvar(gethydro(info), :x, :kpc)        # now physically correct
Mera.getmaskMethod
getmask(obj, condition) -> BitVector
getmask(obj, quantity, predicate; unit=:standard) -> BitVector

Build a boolean selection mask over obj's rows from a value-space condition (FilterCondition, composable with &/|/!) or from a quantity/predicate pair (e.g. getmask(gas, :T, >(1e4); unit=:K)). The mask is computed vectorised through getvar, so it works on any derived quantity; pass it to getvar/projection/ statistics via their mask= keyword without copying the data.

Mera.getmassMethod

Get mass-array from the dataset (cells/particles/clumps/...):

getmass(dataobject::HydroDataType)
getmass(dataobject::PartDataType)
getmass(dataobject::ClumpDataType)

return Array{Float64,1}
Mera.getmovieMethod
getmovie(path, quantity; unit=:standard, datatype=:hydro, outputs=:all, mera_files=false,
         direction=:z, los=nothing, up=nothing, theta=nothing, phi=nothing,
         inclination=nothing, azimuth=nothing, position_angle=nothing, axis=nothing,
         angle_unit=:deg, center=[:boxcenter], range_unit=:standard,
         xrange=[missing,missing], yrange=[missing,missing], zrange=[missing,missing],
         res=nothing, lmax=nothing, weighting=[:mass, missing],
         time_unit=:Myr, verbose=true) -> MeraMovie

Project quantity for every output of a simulation and collect the maps into a MeraMovie — the frames of a movie of the run evolving. Like timeseries it loads one snapshot at a time (RAM-safe) and discovers outputs the same way (RAMSES or mera_files).

The view is the full projection view and is held fixed across frames so the movie is steady. Axis-aligned by default (direction=:z); for an off-axis movie use any of projection's view controls — a los/up (e.g. from face_on/edge_on), the angles inclination/azimuth (or theta/phi, position_angle, with angle_unit), or axis=:angmom to auto-orient face-on. res/lmax and the region keywords cut cost per frame.

m  = getmovie("/data/sim", :sd)                              # face-up density movie, all outputs
fr = face_on(gethydro(getinfo(1, "/data/sim")))             # a fixed orientation …
m  = getmovie("/data/sim", :sd; los=fr.los, up=fr.up, center=fr.center)
savemovie(m, "density.gif")

Returns a MeraMovie; m.frames[k] is the 2D map of output m.outputs[k] at time m.times[k]. See savemovie to write a GIF.

Mera.getparticlemaskMethod
getparticlemask(dataobject::PartDataType, select; verbose=true) -> Vector{Bool}

Boolean mask selecting a subset of particles, for use as the mask= argument of profile, phase, rotationcurve (and projection, getvar, …). select may be

  • a named type:all, :dm (:dark_matter), :stars (:star), :clouds (:sink), :debris, :other, :tracer (family ≤ 0), :gas (gas tracer, family 0);
  • a family code Int, or a vector of codes (matched against the RAMSES :family column);
  • a NamedTuple combining family and/or tag, e.g. (family=2,), (tag=3,), (family=2, tag=1).

On the new RAMSES particle format the :family/:tag columns are used (DM=1, star=2, cloud=3, debris=4, other=5, tracers ≤ 0). On the legacy format (no :family column) only :stars (birth ≠ 0) and :dm (birth == 0) are available via the :birth field; other selections raise an error. The required column must be among the loaded particle variables.

parts = getparticles(getinfo(1, "spiral_ugrid"))
profile(parts, :r_cylinder; weight=:mass, mask=getparticlemask(parts, :stars),
        center=[:bc], range_unit=:kpc, xunit=:kpc)
rotationcurve(parts; mask=getparticlemask(parts, :dm), center=[:bc], range_unit=:kpc)
Mera.getparticlesMethod

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::Array{<:Any,1}=[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 arguments

Returns 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). Set stars=false to drop star particles from the returned table. On the new RAMSES particle format (pversion > 0) this drops rows with family == 2; on the legacy format (no :family column) it drops rows with birth > 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 argument range_unit and relative to the given center; zero length for xmin=xmax=0. is converted to maximum possible length
  • yrange: the range between [ymin, ymax] in units given by argument range_unit and relative to the given center; zero length for ymin=ymax=0. is converted to maximum possible length
  • zrange: the range between [zmin, zmax] in units given by argument range_unit and relative to the given center; zero length for zmin=zmax=0. is converted to maximum possible length
  • range_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 argument range_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 CPU
  • verbose: print timestamp, selected vars and ranges on screen; default: true
  • show_progress: print progress bar on screen
  • myargs: 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.getparticles_gadgetMethod
getparticles_gadget(info::InfoType; families=:all, xrange, yrange, zrange, center,
                    range_unit, verbose=true) -> PartDataType

Read the particles of a GADGET HDF5 snapshot described by info (from getinfo_gadget) into a PartDataType with columns (:x,:y,:z, :vx,:vy,:vz, :mass, :id, :family). :family is the GADGET particle type (0 gas, 1 halo/DM, 2 disk, 3 bulge, 4 stars, 5 boundary/BH). Restrict to a subset with families (e.g. families=[4] for stars, [1,4] for DM+stars).

xrange/yrange/zrange (+ center, range_unit) select a spatial window at load time — particles outside it are dropped per type as they are read, so a sub-region of a large snapshot never accumulates in memory (the RAMSES/grid getparticles convention).

Mera.getparticles_plutoMethod
getparticles_pluto(info::InfoType; verbose=true) -> PartDataType

Read a PLUTO Lagrangian-particle snapshot (particles.NNNN.dbl, single binary file with an ASCII # header) described by info into a Mera PartDataType — columns :x,:y,:z, :id, :vx,:vy,:vz (+ any extra PLUTO particle fields by name), so the particle analysis runs unchanged. Positions are in code length (= info units).

Mera.getpositionsMethod

Get the x,y,z positions from the dataset (cells/particles/clumps/...):

getpositions( dataobject::DataSetType, unit::Symbol;
        direction::Symbol=:z,
        center::Array{<:Any,1}=[0., 0., 0.],
        center_unit::Symbol=:standard,
        mask::MaskType=[false])

return x, y, z

Arguments

Required:

  • dataobject: needs to be of type: "DataSetType"

Predefined/Optional Keywords:

  • center: in unit given by argument center_unit; by default [0., 0., 0.]; the box-center can be selected by e.g. [:bc], [:boxcenter], [value, :bc, :bc], etc..
  • center_unit: :standard (code units), :Mpc, :kpc, :pc, :mpc, :ly, :au , :km, :cm (of typye Symbol) ..etc. ; see for defined length-scales viewfields(info.scale)
  • direction: todo
  • unit: return the variables in given unit
  • mask: needs to be of type MaskType which is a supertype of Array{Bool,1} or BitArray{1} with the length of the database (rows)

Defined Methods - function defined for different arguments

  • getpositions( dataobject::DataSetType; ...) # one given dataobject
  • getpositions( dataobject::DataSetType, unit::Symbol; ...) # one given dataobject and position unit
Mera.getrtMethod

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])    # selected
Mera.getspectrumMethod
getspectrum(c::LosCubeType, i::Integer, j::Integer) -> (centres, values)
getspectrum(c::LosCubeType; x, y, range_unit=c.range_unit) -> (centres, values)

The per-pixel line-of-sight spectrum from a LOS / velocity cube: the binned quantity distribution along the sightline through sky pixel (i,j), or — second form — through the pixel nearest the physical sky position (x, y) (offsets from the cube centre, in range_unit).

Returns the bin centres and the per-bin weight (e.g. mass), ready to plot as a line: lines(getspectrum(vc; x=0, y=0)...). For a velocity cube the centres are line-of-sight velocities (a synthetic emission-line profile); for a los_cube(:T) they are temperatures (a PDF). Integrating values over the bins recovers that pixel's column (the moment-0 value).

Mera.gettimeMethod
gettime(output::Real; path::String="./", unit::Symbol=:standard)
gettime(dataobject::DataSetType; unit::Symbol=:standard)
gettime(dataobject::InfoType, unit::Symbol=:standard)

Get the physical simulation time in selected units. Returns a Float64.

For a cosmological run (see iscosmological) info.time is conformal time, so gettime instead returns the age of the universe at the snapshot's scale factor (from cosmology), converted to unit. Supported units for cosmological runs: :Gyr, :Myr, :yr, :s (:standard ⇒ seconds). For a non-cosmological run the behaviour is unchanged (info.time scaled to unit).

gettime(1, path="/path/to/sim", unit=:Myr)
gettime(gas, unit=:Gyr)
gettime(info, :Myr)

Arguments Function 1

Required:

  • output: give the output-number of the simulation

Predefined/Optional Keywords:

  • path: the path to the output folder relative to the current folder or absolute path
  • unit: return the variable in given unit

Arguments Function 2

Required:

  • dataobject: needs to be of type: "DataSetType"

Predefined/Optional Keywords:

  • unit: return the variable in given unit

Arguments Function 3

Required:

  • dataobject: needs to be of type: "InfoType"

Predefined/Optional Keywords:

  • unit: return the variable in given unit
Mera.getvarMethod

Get variables or derived quantities from the dataset:

  • overview the list of predefined quantities with: getinfo()
  • select variable(s) and their unit(s)
  • give the spatial center (with units) of the data within the box (relevant e.g. for radius dependency)
  • relate the coordinates to a direction (x,y,z)
  • pass a modified database
  • pass a mask to exclude elements (cells/particles/...) from the calculation
getvar(   dataobject::DataSetType, var::Symbol;
        filtered_db::IndexedTables.AbstractIndexedTable=IndexedTables.table([1]),
        center::Array{<:Any,1}=[0.,0.,0.],
        center_unit::Symbol=:standard,
        direction::Symbol=:z,
        unit::Symbol=:standard,
        mask::MaskType=[false],
        ref_time::Real=dataobject.info.time)

return Array{Float64,1}

Arguments

Required:

  • dataobject: needs to be of type: "DataSetType"
  • var(s): select a variable from the database or a predefined quantity (see field: info, function getvar(), dataobject.data)

Predefined/Optional Keywords:

  • filtered_db: pass a filtered or manipulated database together with the corresponding DataSetType object (required argument)
  • center: in units given by argument center_unit; by default [0., 0., 0.]; the box-center can be selected by e.g. [:bc], [:boxcenter], [value, :bc, :bc], etc..
  • center_unit: :standard (code units), :Mpc, :kpc, :pc, :mpc, :ly, :au , :km, :cm (of typye Symbol) ..etc. ; see for defined length-scales viewfields(info.scale)
  • direction: todo
  • unit(s): return the variable in given units
  • mask: needs to be of type MaskType which is a supertype of Array{Bool,1} or BitArray{1} with the length of the database (rows)
  • ref_time: reference zero-time for particle age calculation

Defined Methods - function defined for different arguments

  • getvar( dataobject::DataSetType, var::Symbol; ...) # one given variable -> returns 1d array
  • getvar( dataobject::DataSetType, var::Symbol, unit::Symbol; ...) # one given variable with its unit -> returns 1d array
  • getvar( dataobject::DataSetType, vars::Array{Symbol,1}; ...) # several given variables -> array needed -> returns dictionary with 1d arrays
  • getvar( dataobject::DataSetType, vars::Array{Symbol,1}, units::Array{Symbol,1}; ...) # several given variables and their corresponding units -> both arrays -> returns dictionary with 1d arrays
  • getvar( dataobject::DataSetType, vars::Array{Symbol,1}, unit::Symbol; ...) # several given variables that have the same unit -> array for the variables and a single Symbol for the unit -> returns dictionary with 1d arrays

Examples

# read simulation information
julia> info = getinfo(420)
julia> gas = gethydro(info)

# Example 1: get the mass for each cell of the hydro data (1dim array)
mass1 = getvar(gas, :mass)  # in [code units]
mass = getvar(gas, :mass) * gas.scale.Msol # scale the result from code units to solar masses
mass = getvar(gas, :mass, unit=:Msol) # unit calculation, provided by a keyword argument
mass = getvar(gas, :mass, :Msol) # unit calculation provided by an argument


# Example 2: get the mass and |v| (several variables) for each cell of the hydro data
quantities = getvar(gas, [:mass, :v]) # in [code units]
returns: Dict{Any,Any} with 2 entries:
  :mass => [8.9407e-7, 8.9407e-7, 8.9407e-7, 8.9407e-7, 8.9407e-7, 8.9407e-7, 8…
  :v => [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0  …  2.28274e-7, 2.…

quantities = getvar(gas, [:mass, :v], units=[:Msol, :km_s]) # unit calculation, provided by a keyword argument
quantities = getvar(gas, [:mass, :v], [:Msol, :km_s]) # unit calculation provided by an argument

# Example 3: get several variables in the same units by providing a single argument
quantities = getvar(gas, [:vx, :vy, :vz], :km_s)
...

Radiative transfer (RT) quantities

For an RT run (rt = getrt(info)) the stored variables are, per photon group g, the photon number density :Np<g> and the flux components :Fx<g>, :Fy<g>, :Fz<g> (code units). Derived RT quantities on the RT object:

  • :Fmag<g> flux magnitude |F_g| = √(Fx²+Fy²+Fz²) [code units]
  • :Np_total photon number density summed over all groups [code units]
  • :reducedflux<g> reduced flux f = |Fg| / (c·Npg), dimensionless in 0,1
  • :Np<g>_cgs physical photon number density = Npg · unitnp [photons cm⁻³]
  • :Fmag<g>_cgs physical flux magnitude = |Fg| · unitpf [photons cm⁻² s⁻¹]
  • :photon_energy_density<g> radiation energy density of group g = Npg · unitnp · egyg [erg cm⁻³] (egyg = mean photon energy from info.descriptor.rt[:group_egy])
  • :rad_energy_density total radiation energy density summed over all groups [erg cm⁻³]

The per-group photon properties parsed from info_rt (mean energy, energy bounds, photoionization cross-sections, species→group map) are available in info.descriptor.rtPhotonGroups ([g][:egy_eV], [:csn_cm2], [:cse_cm2], plus [:L0_eV], [:L1_eV], [:spec2group]).

The ionization fractions are passive hydro scalars (located via the RT descriptor info.descriptor.rt[:iIons]); request them on the hydro object (gas = gethydro(info)):

  • :xHII, :xHeII, :xHeIII ionization fractions (dimensionless)
  • :xHI neutral atomic-hydrogen fraction (a stored scalar with H2 chemistry, else the closure 1 − xHII; dimensionless)
  • :xH2 molecular-hydrogen fraction = (1 − xHI − xHII)/2 (H2-chemistry runs only; ½ ⇒ fully molecular)
  • :n_HII, :n_HI, :n_e, :n_H2 HII / HI / free-electron / H₂ number density cm⁻³
  • :em_recomb recombination-emissivity proxy ∝ nₑ·nHII ≈ nHII² cm⁻⁶
  • :mu RT-aware mean molecular weight from the ionization (and, with H2 chemistry, molecular) state and metallicity: μ = 1/[XH·hₚ + (XHe/4)(1+xHeII+2xHeIII) + Z/AZ], where hₚ = 1+xHII (no H2) or xHI+2·xHII+xH2 (H2); XH/XHe scaled by the local metal mass fraction Z (the :metallicity scalar, 0 if absent) and AZ≈16. Metal free electrons are neglected (RT does not track metal ionization).
H₂-enabled RAMSES-RT runs

With molecular-hydrogen chemistry (Nickerson et al. 2018) RAMSES stores an extra xHI scalar before xHII, so the species order becomes [xHI, xHII, xHeII, xHeIII] and nIons is even. Mera detects this from nIons (isH2 = iseven(nIons), isHe = nIons≥3) and remaps :xHII/:xHeII/:xHeIII/:n_*/:mu/:T_rt accordingly, and exposes :xHI, :xH2, :n_H2. (Standard non-H₂ runs are unchanged.)

  • :T_rt gas temperature [K] using the local μ (= (P/ρ)·scale.Tmu·μ). Plain :T (unit=:K) bakes in a constant μ (= scale.K/scale.Tmu ≈ 1/0.76 ≈ 1.32, the fixed primordial default — independent of the run's X), so it over-estimates the ionized-gas temperature by μconst/μlocal (e.g. ≈1.32/0.5 ≈ 2.6× for fully-ionized pure hydrogen). Prefer :T_rt for RT runs.
rt   = getrt(info)
gas  = gethydro(info)
f    = getvar(rt, :reducedflux1)                 # reduced flux of group 1
nphot = getvar(rt, :Np1_cgs)                     # physical photon density [cm^-3]
xHII = getvar(gas, :xHII)                        # ionization fraction (hydro scalar)
ne   = getvar(gas, :n_e)                         # free-electron density [cm^-3]
T    = getvar(gas, :T_rt)                        # RT-aware temperature [K] (local μ)

:mu and :T_rt also work on non-RT hydro runs: without tracked ionization fractions they fall back to the constant μ Mera's temperature scaling assumes (μ = scale.K/scale.Tmu), so there `:Trtequalsgetvar(:T, :K). The other RT quantities (:xHII,:xHI,:n*,:emrecomb`) require an RT run and error otherwise.

RAMSES-RT field reference (physical quantity → Mera accessor):

quantity (per photon group i / ion)Mera
photon number densitygetvar(rt, :Npi)unit_np:Npi_cgs)
photon flux componentsgetvar(rt, :Fxi/:Fyi/:Fzi) (magnitude :Fmagi``)
reduced flux (M1 closure):reducedfluxi``
HII ionization fractiongetvar(gas, :xHII)
HeII / HeIII fractions:xHeII / :xHeIII
HII / HI / electron density:n_HII / :n_HI / :n_e

Radiation–matter rates (RT object; use the reduced light speed rt_c_frac·c):

  • :Gamma_HI<g>, :Gamma_HI HI photoionization rate per group / total [s⁻¹]
  • :photoheating_HI<g>, :photoheating_HI HI photoheating rate per HI atom [erg s⁻¹]

Recombination (hydro object): :recomb_rate = αB(T)·nₑ·nHII cm⁻³ s⁻¹.

Combined radiation+gas — request on the RT object with the matching hydro_data (both loaded over the same cells); Mera asserts the cell sets align:

  • :photoionizations = ΓHI·nHI [cm⁻³ s⁻¹]
  • :ionization_balance = photoionizations − recombinations (≈0 in local equilibrium)
rt  = getrt(info);  gas = gethydro(info)            # same lmax/ranges → aligned cells
Γ   = getvar(rt, :Gamma_HI)                          # photoionization rate [1/s]
bal = getvar(rt, :ionization_balance, hydro_data=gas)  # Γ·n_HI − α_B·nₑ·n_HII  [cm^-3 s^-1]

Most RT quantities are single-object (photon fields on rt, ionization state on gas); only the coupling terms above need both. For other hydro variables you may also pass hydro_data=gas to getvar(rt, …) to fetch them aligned to the RT cells.

Mera.getvarMethod

Get gravity data with hydro data as second positional argument

New simplified syntax:

# Single variable with unit
getvar(grav, hydro, :jeansmass, :Msol)

# Multiple variables with units  
getvar(grav, hydro, [:jeansmass, :epot], [:Msol, :erg])

# Multiple variables with same unit
getvar(grav, hydro, [:T, :cs], :K)
Mera.getvarMethod

Get gravity data with optional hydro data for advanced energy analysis

Arguments:

  • dataobject: needs to be of type: "GravDataType"
  • var: select a variable from the database or a predefined quantity

Keyword Arguments:

  • hydro_data: optional hydro data object for energy calculations that require density/mass
  • center: center position (default: [0.,0.,0.])
  • direction: direction for cylindrical coordinates (default: :z)
  • ...

Examples:

# Basic gravity analysis
grav_data = getvar(grav, :epot)

# Advanced energy analysis with hydro data (keyword syntax)
energy_density = getvar(grav, :gravitational_energy_density, hydro_data=hydro)
binding_energy = getvar(grav, :gravitational_binding_energy, hydro_data=hydro)

# NEW: Simplified positional syntax
jeans_mass = getvar(grav, hydro, :jeansmass, :Msol)
thermal_energy = getvar(grav, hydro, :etherm, :erg)
mixed_analysis = getvar(grav, hydro, [:epot, :T, :jeanslength], [:erg, :K, :pc])
Mera.getvar_requirementsMethod
getvar_requirements(kind::Symbol, vars) -> Vector{Symbol}

The sorted set of physical stored variables that must be read to compute vars (a Symbol or a collection), with always-present geometry leaves (:cx/:cy/:cz, :level, :x/:y/:z, :cellsize, :volume, …) removed. Unknown/custom symbols are returned as-is (callers can detect these and fall back to reading everything).

getvar_requirements(:hydro, :ekin)        # [:rho, :vx, :vy, :vz]
getvar_requirements(:hydro, [:sd, :T])    # [:rho, :p]   (:sd is an alias of surface density → :rho)
Mera.getvelocitiesMethod

Get the vx,vy,vz velocities from the dataset (cells/particles/clumps/...):

function getvelocities( dataobject::DataSetType, unit::Symbol;
    mask::MaskType=[false])

return vx, vy, vz

Arguments

Required:

  • dataobject: needs to be of type: "DataSetType"

Predefined/Optional Keywords:

  • unit: return the variables in given unit
  • mask: needs to be of type MaskType which is a supertype of Array{Bool,1} or BitArray{1} with the length of the database (rows)

Defined Methods - function defined for different arguments

  • getvelocities( dataobject::DataSetType; ...) # one given dataobject
  • getvelocities( dataobject::DataSetType, unit::Symbol; ...) # one given dataobject and velocity unit
Mera.gridoverlay!Function
gridoverlay!(ax, go; color=(:white,0.3), linewidth=0.4)

Draw a gridoverlay result go onto a Makie axis ax (the AMR cell boundaries). Available after using Makie/CairoMakie.

Mera.gridoverlayMethod
gridoverlay(dataobject; level=:max, direction=:z, center=[:boxcenter], range_unit=:standard,
            xrange=[missing,missing], yrange=[missing,missing], zrange=[missing,missing],
            unit=:standard) -> (segments, extent, level)

Cell-boundary line segments of the AMR cells at one refinement level, viewed along direction (:x/:y/:z), for overlaying the AMR structure on a map. level is :max (default, the finest), :min, or an integer. The cell edges are de-duplicated.

The result is the 2-D footprint of that level's cells (collapsed along direction), so it suits both a projection and a slice:

  • slice — pass a thin zrange (the slice plane) → the exact in-plane cell grid there;
  • projection — use the full column → where that level's cells project to along the line of sight.

(The two coincide when the refined region is a column-aligned box, and differ for irregular refinement.)

Off-axis views work too: pass the same view keywords as projectionlos/up, inclination/azimuth (or theta/phi, position_angle), axis=:angmom, or direction=:faceon/:edgeon. Each cell centre is projected through the camera basis and drawn as a cell-sized square (an approximate indicator; the true tilted-cube silhouette is a hexagon). Off-axis overlays are not edge-de-duplicated, so on dense AMR pick a coarser level or a sub-region to keep the segment count manageable.

Returns a NamedTuple: segments (a Vector{NTuple{4,Float64}} of (x1,y1,x2,y2) in the plane coordinates and unit), extent [xmin,xmax,ymin,ymax], and the level used. Plot with linesegments! — or, after using Makie, the convenience gridoverlay!(ax, go).

p  = projection(gas, :sd)
go = gridoverlay(gas; level=:max)         # the finest-cell grid, where it exists
# overlay go.segments on the heatmap of p.maps[:sd]
Mera.humanizeMethod

Convert a value to human-readable astrophysical units and round to ndigits

(pass the value in code units and the quantity specification (length, time) )

function humanize(value::Float64, scale::ScalesType003, ndigits::Int, quantity::String)

return value, value_unit
Mera.infodataMethod

Get the simulation overview from RAMSES, saved in JLD2 == function getinfo

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

# 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)
...
Mera.integrated_spectrumMethod
integrated_spectrum(c::LosCubeType; mask=nothing) -> (bins, values)

The integrated (global) spectrum of a LOS / velocity cube: the per-pixel spectra summed over the whole sky map (or over a boolean mask of size (nx, ny)) — the synthetic global line profile (e.g. an HI/CO single-dish profile). Returns the bin centres and the summed weight per channel. Summing values over the channels equals the cube's total deposited weight (the moment-0 total, e.g. the enclosed mass for a velocity cube).

Mera.interactive_mera_converterMethod
interactive_mera_converter(input_dir::String, output_dir::String;
                                   safety_margin::Float64=DEFAULT_SAFETY_MARGIN,
                                   min_threads::Int=DEFAULT_MIN_THREADS,
                                   max_threads::Int=DEFAULT_MAX_THREADS)

Interactive mode for file conversion with comprehensive user guidance and system information.

This function provides a user-friendly interface that:

  1. Displays comprehensive system information and constraints
  2. Analyzes available files and detects potential issues
  3. Guides user through range and thread count selection
  4. Provides intelligent recommendations based on system state
  5. Executes conversion with all safety monitoring features

User Experience Flow

System Information Display

  • Shows CPU core count and memory configuration
  • Displays current memory usage and safety margin status
  • Indicates thread count limits and recommendations
  • Warns about any current resource constraints

File Analysis and Validation

  • Scans input directory for valid RAMSES files
  • Reports total file count and available output ranges
  • Detects and reports gaps in file sequences
  • Helps user identify potential data integrity issues

Guided Parameter Selection

  • Prompts for output number range with sensible defaults
  • Recommends thread count based on system capacity and safety constraints
  • Allows user override with explanation of implications
  • Provides real-time feedback on selections

Safety-Monitored Execution

  • Calls main conversion function with user-selected parameters
  • Provides same comprehensive monitoring as batch function
  • Returns complete results for user review

Parameters

  • input_dir: Source directory containing old JLD2 files
  • output_dir: Destination directory for converted files
  • safety_margin: Memory usage threshold (default: 0.8 = 80%)
  • min_threads: Minimum thread count (default: 1)
  • max_threads: Maximum thread count (default: 64)

Example Usage

Basic interactive mode interactivemeraconverter("/data/old", "/data/new")

Conservative interactive mode for large files interactivemeraconverter("/data/old", "/data/new"; safetymargin=0.9, maxthreads=8)

Mera.iops_testMethod
iops_test(files; runs=3, levels=[1,2,4,8,16,24,32,48,64],
           max_threads=Threads.nthreads())

Measures file-open IOPS across thread counts. Returns (samples, stats, elapsed).

Mera.iscosmologicalMethod
iscosmological(info::InfoType) -> Bool

Return true if the simulation is a cosmological RAMSES run, false for a non-cosmological ("idealised") run.

The decision uses the physical cosmology fields RAMSES writes into the info file. A non-cosmological run carries the sentinels aexp = 1 and omega_l = 0; any deviation (a dark-energy density, or a scale factor ≠ 1) marks a cosmological run.

info = getinfo(80, "…/yt_cosmo")
iscosmological(info)   # true
Mera.list_fieldsFunction
list_fields(kind::Symbol=:hydro; builtin::Bool=false) -> Vector{Symbol}

The registered derived-field names for a data-type kind (:hydro, :gravity, :rt, :particle, :clump), sorted.

By default only the user-added fields (registered with add_field) are returned — this is the back-compatible behaviour. With builtin=true the result also includes the built-in derived quantities known to the dependency registry (FIELD_DEPS[kind]), so you get a single combined list of everything resolvable for that kind:

list_fields(:hydro)                 # only the fields you added
list_fields(:hydro; builtin=true)   # built-in registry fields ∪ your custom fields

Note: builtin=true reflects the dependency registry, which covers most but not every built-in quantity (a few specialised fields, e.g. some RT-ionization variables, are computed directly in getvar without a registry entry). For the full human-readable catalogue call getvar() with no arguments.

Mera.load_synthetic_clumpsFunction
load_synthetic_clumps(file_or_dir="."; download=false, url=Mera.SYNTH_URL) -> NamedTuple

Load the synthetic clump field, returning (; gas, particles, truth). file_or_dir is either the .jld2 file itself or a directory containing mera_synthetic_clumps.jld2.

With download=true the file is fetched from url (the GitHub release asset) when it is not already present locally. The stored objects are standard Mera data types, so every Mera verb (getvar, projection, clumpfind, …) works on them — using Mera is all that is needed.

D = load_synthetic_clumps(tempdir(); download=true)   # fetch once, then load
clumpfind(D.gas, ThresholdFoF(:rho; threshold=5.0, linking_length=2.0/2^7))
Mera.loadcubeMethod
loadcube(filename; verbose=true) -> LosCubeType

Load a LOS / velocity cube saved with savecube from a JLD2 file (the .jld2 extension is added if missing). The cube, its axes, the binned quantity/units, the camera basis and the simulation info all round-trip, and the reconstructed cube is validated.

Mera.loaddataMethod

Read stored simulation data into a dataobject:

  • supported datatypes: HydroDataType, PartDataType, GravDataType, ClumpDataType
  • select a certain data range (data is fully loaded; the selected subregion is returned)
  • toggle verbose mode
function loaddata(output::Int; path::String="./",
            fname = "output_",
            datatype::Symbol,
            xrange::Array{<:Any,1}=[missing, missing],
            yrange::Array{<:Any,1}=[missing, missing],
            zrange::Array{<:Any,1}=[missing, missing],
            center::Array{<:Any,1}=[0., 0., 0.],
            range_unit::Symbol=:standard,
            verbose::Bool=true,
            myargs::ArgumentsType=ArgumentsType() )

return dataobject

Arguments

Required:

  • output: output number
  • datatype: :hydro, :particles, :gravity, :clumps or :rt

Predefined/Optional Keywords:

  • path: path to the file; default is local path.
  • fname: default name of the files "output_" and the running number is added. Change the string to apply a user-defined name.
  • xrange: the range between [xmin, xmax] in units given by argument range_unit and relative to the given center; zero length for xmin=xmax=0. is converted to maximum possible length
  • yrange: the range between [ymin, ymax] in units given by argument range_unit and relative to the given center; zero length for ymin=ymax=0. is converted to maximum possible length
  • zrange: the range between [zmin, zmax] in units given by argument range_unit and relative to the given center; zero length for zmin=zmax=0. is converted to maximum possible length
  • range_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)
  • myargs: pass a struct of ArgumentsType to pass several arguments at once and to overwrite default values of xrange, yrange, zrange, center, range_unit, verbose
  • verbose: print timestamp and further information on screen; default: true

Defined Methods - function defined for different arguments

  • loaddata(output::Int64; ...) # opens first datatype in the file
  • loaddata(output::Int64, datatype::Symbol; ...)
  • loaddata(output::Int64, path::String; ...)
  • loaddata(output::Int64, path::String, datatype::Symbol; ...)
Mera.loadmapMethod
loadmap(filename; verbose=true) -> DataMapsType

Load a projection result saved with savemap from a JLD2 file (the .jld2 extension is added if missing). The whole AMRMapsType/PartMapsType round-trips — maps, units, geometry, camera basis, and info — ready to plot, re-project, or carry provenance.

Mera.loadmovieMethod
loadmovie(filename; verbose=true) -> MeraMovie

Load a MeraMovie saved with savemovie(m, "….jld2"). The numeric frames and metadata round-trip exactly, so you can re-savemovie it to a GIF (with different tags/colormap) without re-running getmovie. JLD2-native, like loadmap/loadcube.

Mera.loadreportMethod
loadreport(filename) -> QuickReport

Reload a [QuickReport] written with render(report, :jld2) (or :file).

Mera.localdispersionMethod
localdispersion(dataobject; patchsize=[500,:pc], components=(:vr_cylinder,:vϕ_cylinder,:vz),
                weight=:mass, vunit=:km_s, thermal=true, mu=1.0, Tvar=:T,
                center=[:bc], range_unit=:standard, mask=[false], min_cells_per_patch=20,
                quantiles=[0.16,0.5,0.84]) -> NamedTuple

Local (patch-de-streamed) velocity dispersion — turbulent ⊕ thermal. The TIGRESS/SILCC-style turbulence measure: the field of view is tiled into square patchsize patches in the (x, y) plane, the per-patch mass-weighted mean velocity is subtracted from every cell (so bulk rotation, shear and spiral streaming on scales larger than patchsize are removed), and the residual dispersion is the genuine small-scale turbulence below patchsize.

This differs from velocitydispersion, which removes the mean per radial bin: here the de-streaming is on a spatial grid, so it does not absorb non-circular streaming into "turbulence". Restrict the input first (e.g. shellregion to a solar annulus, and/or a midplane mask) — this returns aggregate scalars over the whole supplied region, not a radial profile.

Per the supplied region it returns the mass-weighted aggregate:

  • sigma_r,sigma_phi,sigma_z (the components order), sigma_turb_3d = √(Σσ_i²), sigma_turb_1d = √(Σσ_i²/n);
  • with thermal=true: sigma_thermal = √(k_B⟨T⟩/(μ m_H)), sigma_total = √(sigma_turb_1d²+sigma_thermal²);
  • mach = sigma_turb_1d/⟨c_s⟩, anisotropy = sigma_z/σ_in-plane (for a 3-component triplet, z last);
  • n_cell, n_eff (Kish), n_patch, and the patch-to-patch weighted percentiles of σtotal / Mach / anisotropy at quantiles (`sigmatotalq,machq,anisotropyq) — the physical region-to-region scatter, suitable as error bars. Only patches with ≥mincellsperpatch` cells enter the percentiles.

mu is the tracer mean molecular weight in H-atom masses (2.33 molecular, 1.0 atomic, 0.6 ionized).

Mera.log_envMethod
log_env()

Prints Julia version, OS, CPU threads, timestamp, hostname, working directory, and project dependencies for reproducibility.

Mera.los_componentMethod
los_component(dataobject, vector; <view kwargs>, weight=:mass, unit=:standard,
              dispersion=false, res=256, pxsize=[size,:unit], center=[:bc], range_unit=:standard)
    -> NamedTuple(map, dispersion, los, up, cam_right, center, pixsize, range_unit, unit, x, y)

Mass-weighted 2D map of the line-of-sight component vector·ŵ of an arbitrary vector field, given as a 3-tuple of getvar symbols — e.g. (:vx,:vy,:vz) ⇒ vₗₒₛ, (:ax,:ay,:az) ⇒ LOS acceleration (gravity), (:bx,:by,:bz) ⇒ LOS magnetic field. dispersion=true returns the dispersion instead of the mean.

Returns a NamedTuple whose .map field holds the 2D array (the mean LOS component, or its dispersion when dispersion=true); the .dispersion flag, the camera basis (los/up/ cam_right), numeric center, pixsize, range_unit, unit, and the code-unit bin-edge axes x/y travel with it (so it can be fed to mock_observe and carries provenance).

Mera.los_cubeMethod
los_cube(dataobject; quantity=:vlos, <view kwargs>, nbins=64, qrange=nothing, q_unit=:standard,
         weight=:mass, res=256, pxsize=[size,:unit], xrange=[missing,missing], yrange=[missing,missing], center=[:bc],
         range_unit=:standard, binning=:overlap, mask=[false]) -> LosCubeType

Off-axis line-of-sight distribution cube: cube[i,j,k] is the deposited weight (default mass) at sky pixel (i,j) in bin k of the line-of-sight quantity. The distribution along each sightline, per pixel — i.e. a "spectrum". quantity may be

  • a scalar field name (:T, :rho, :cs, …) → its per-sightline distribution (a PDF),
  • :vlos → the line-of-sight velocity (a spectral / velocity-channel cube), or
  • a 3-vector of component names ((:vx,:vy,:vz), (:ax,:ay,:az), (:bx,:by,:bz)) → its line-of-sight component vector·ŵ.

The view is chosen with the same keywords as projection. binning accepts the centre-deposit previews :cic/:ngp and the hole-free footprint modes :overlap/:exact (default :overlap, recommended for maps when pixels are finer than cells). qrange (the LOS-axis range) is in the scaled q_unit; samples outside an explicit qrange are dropped. weight should be a cumulative/extensive quantity (:mass, default, or :volume) — it is summed along each sightline, so an intensive field like :rho/:T would give a non-physical "summed density" cube. Returns a LosCubeType; store it with savecube. los_moments gives the column/mean/dispersion maps. cube's sky-pixel edges x/y are in code length units.

Mera.los_momentsMethod
los_moments(c::LosCubeType) -> (Σ, mean, dispersion)

Moment-0/1/2 maps of a LOS cube c: the column Σ (summed weight, e.g. column mass), the weight-weighted mean of the binned quantity, and its dispersion — each a 2D array.

Discretization bias of the dispersion

The moments are computed from the cube's bin centres, so the dispersion is biased high by roughly the Sheppard correction σ²true ≈ σ²measured − Δ²/12, where Δ = bin width (step(c.bins)). The bias is negligible once a feature spans several bins (Δ ≪ σ); it only matters for under-resolved, near-delta distributions. To reduce it, build the cube with more nbins or a tighter qrange. For an unbinned (bias-free) dispersion of a vector's LOS component, use los_component(...; dispersion=true), which accumulates the moments from the continuous per-cell samples directly.

Mera.makefileMethod

Get a printout of the makefile:

makefile(object::InfoType)
Mera.map_amr_cells_to_grid!Method
map_amr_cells_to_grid!(grid, weight_grid, x_coords, y_coords, values, weights, 
                      level, grid_extent, grid_resolution, boxlen)

Map AMR cells from one refinement level to a regular 2D grid with proper geometric handling.

This is the core function that converts AMR simulation data to gridded projections. It handles the coordinate transformation from 1-based RAMSES grid indices to physical coordinates and properly accounts for cell size, overlap, and area weighting.

Arguments

  • grid::AbstractMatrix{Float64}: Output grid for accumulated values (modified in-place)
  • weight_grid::AbstractMatrix{Float64}: Output grid for accumulated weights (modified in-place)
  • x_coords, y_coords::AbstractVector: AMR cell coordinates (1-based grid indices)
  • values::AbstractVector{Float64}: Physical quantity values for each cell
  • weights::AbstractVector{Float64}: Weighting values for each cell (usually mass)
  • level::Int: AMR refinement level (determines cell size = boxlen/2^level)
  • grid_extent::NTuple{4,Float64}: (xmin, xmax, ymin, ymax) in physical units
  • grid_resolution::NTuple{2,Int}: (nx, ny) pixel dimensions of output grid
  • boxlen::Float64: Physical size of simulation domain

Algorithm

  1. Transform 1-based grid indices to physical coordinates
  2. Calculate cell boundaries (center ± halfcellsize)
  3. Find overlapping grid pixels using geometric intersection
  4. Distribute cell value/weight proportionally to overlap area
  5. Handle boundary cases and ensure no gaps in coverage

Performance Notes

  • Uses @inbounds for speed in tight loops
  • Pre-computes constants to avoid repeated calculations
  • Conservative boundary handling prevents coordinate edge cases
Mera.map_amr_cells_to_grid_adaptive!Method
map_amr_cells_to_grid_adaptive!(grid, weight_grid, x_coords, y_coords, values, weights, 
                               level, grid_extent, grid_resolution, boxlen; verbose=false)

Intelligent algorithm dispatcher that selects the optimal mapping approach based on data size.

This function analyzes the dataset characteristics and automatically chooses between:

  • Direct mapping: Efficient for small-medium datasets (< 50k cells or < 10k pixels)
  • Spatial indexing: Optimized for large datasets with spatial locality benefits

Performance Heuristics

  • Large datasets (>50k cells + >10k pixels): Uses hierarchical spatial bins for O(n log n) performance
  • Smaller datasets: Uses direct O(n×m) approach with better cache locality

Arguments

Same as base mapping function, plus:

  • verbose::Bool=false: Print algorithm selection information
Mera.map_amr_cells_to_grid_surface_density!Method
map_amr_cells_to_grid_surface_density!(grid, weight_grid, x_coords, y_coords, values, weights,
                                      level, grid_extent, grid_resolution, boxlen)

Specialized mapping function for surface density calculations with RAMSES-consistent precision.

This function is optimized for surface density (mass per unit area) projections where precise geometric overlap calculations are essential for accurate mass conservation. It uses the same coordinate transformation as the main mapping function but with additional safeguards for mass conservation.

Key Features

  • RAMSES-consistent coordinate handling: (gridindex - 0.5) * cellsize
  • Exact geometric overlap calculation for precise mass distribution
  • Perfect alignment across all AMR refinement levels
  • Mass conservation through careful area weighting

Arguments

Same as map_amr_cells_to_grid! but optimized for surface density calculations.

Algorithm

  1. Transform coordinates using RAMSES convention
  2. Calculate precise cell-pixel overlap areas
  3. Distribute mass proportional to overlap area
  4. Maintain exact mass conservation across refinement levels
Mera.map_amr_cells_to_grid_with_spatial_index!Method
map_amr_cells_to_grid_with_spatial_index!(grid, weight_grid, x_coords, y_coords, values, weights, 
                                         level, grid_extent, grid_resolution, boxlen)

High-performance mapping using hierarchical spatial indexing for large datasets.

This function implements a two-phase algorithm optimized for scenarios with many AMR cells:

  1. Spatial Indexing Phase: Divides the grid into spatial bins and indexes which cells affect each bin
  2. Processing Phase: Processes cells bin-by-bin for optimal cache locality and reduced redundant calculations

Performance Characteristics

  • Time Complexity: O(n log n) vs O(n×m) for direct approach
  • Memory: Uses spatial bins that scale with √n for optimal performance
  • Cache Locality: Processes spatially adjacent cells together
  • Best For: Datasets with >50k cells and large grids (>10k pixels)

Algorithm Details

  • Adaptive Bin Sizing: Bin size adapts to cell count for optimal performance
  • Hierarchical Indexing: Cells are indexed into spatial bins for fast lookup
  • Same Coordinate System: Uses identical RAMSES coordinate transformation as direct method
  • Identical Results: Produces exactly the same output as direct method, just faster
Mera.massfunctionplotMethod
massfunctionplot(cat::ClumpCatalog; cumulative=false, nbins=20, kwargs...) -> Makie.Figure

Plot the clump mass function from a ClumpCatalog (via clump_massfunction): the differential dN per mass bin, or the cumulative N(≥M) when cumulative=true, on log axes. Needs a Makie backend loaded (using CairoMakie).

using CairoMakie
fig = massfunctionplot(cat; cumulative=true)
Mera.mean_baryon_densityMethod
mean_baryon_density(info::InfoType) -> Float64

Mean (proper) baryon mass density at the snapshot redshift, ρ̄_b = Ωb · ρ_crit,0 · (1+z)³ [g/cm³]. This is the reference density for the gas overdensity getvar(hydro, :overdensity).

Mera.mean_matter_densityMethod
mean_matter_density(info::InfoType) -> Float64

Mean (proper) matter mass density at the snapshot redshift, ρ̄_m = Ωm · ρ_crit,0 · (1+z)³ [g/cm³].

Mera.mera_io_statusMethod
mera_io_status()

Quick status check of Mera I/O configuration and performance.

Returns a summary of current settings and cache performance in a compact format.

Example

julia> mera_io_status()
"I/O: 128KB buffer, cache enabled (5 files), optimized ✅"
Mera.mock_observeMethod
mock_observe(map2d; beam_fwhm, pixsize=1.0, noise=0.0, rng=nothing) -> Matrix
mock_observe(m::DataMapsType, var; beam_fwhm, beam_unit=:standard,
             distance=0.0, distance_unit=:standard, noise=0.0, rng=nothing) -> Matrix

Convolve a 2D map with a Gaussian beam of full-width-half-maximum beam_fwhm and (optionally) add Gaussian noise (standard deviation, in map units), returning the "observed" image.

  • Matrix form: pixsize is the physical size of a pixel and beam_fwhm is in the same unit (so beam_fwhm/pixsize is the beam in pixels).
  • DataMapsType form: pass a projection result m and a variable key; the pixel size is taken from m.pixsize. beam_fwhm is interpreted in beam_unit:
    • a physical unit (:kpc, :pc, …) — a beam fixed in physical size;
    • an angular unit (:arcsec, :arcmin, :deg, :rad) with a source distance (in distance_unit) — the beam is θ[rad] × distance physical (small-angle). Use Mera's cosmology helpers for the angular-diameter distance of a redshifted source.

Beam σ = FWHM / (2√(2 ln 2)). Convolution uses a Gaussian kernel (Images.jl imfilter). Pass a seeded rng for reproducible noise.

Mera.moment2Function
moment2(dataobject, quantity [, unit]; weight=:mass, <view & range kwargs>) -> NamedTuple

Off-axis line-of-sight dispersion (moment 2) of an arbitrary field quantity: the weight-weighted standard deviation σ = √(⟨q²⟩w − ⟨q⟩w²) of q along each sightline. Works for quantity=:vlos (reproduces the σlos map), any scalar getvar field (:T, :rho, …), or a 3-vector (:vx,:vy,:vz) (its line-of-sight component). Returns the same metadata-carrying result as los_component.map holds the dispersion; the matching mean (moment 1) is los_component(dataobject, quantity; …).

Mera.moviefromframesFunction
moviefromframes(dir, file="movie.gif"; pattern=r"\.png$"i, fps=10, verbose=true) -> file

Assemble an animated GIF from existing image files in dir (e.g. PNG frames you rendered yourself, or wrote earlier with savemovie(...; save_frames=dir)). Files matching pattern are sorted by name and stacked in that order. The complement to savemovie's save_frames.

moviefromframes("frames/", "movie.gif"; fps=12)
Mera.msumMethod

Calculate the total mass of any ContainMassDataSetType:

msum(dataobject::ContainMassDataSetType; unit::Symbol=:standard, mask::MaskType=[false])

return Float64

Arguments

Required:

  • dataobject: needs to be of type: "ContainMassDataSetType"

Optional Keywords:

  • unit: the unit of the result (can be used w/o keyword): :standard (code units) :Msol, :Mearth, :Mjupiter, :g, :kg (of typye Symbol) ..etc. ; see for defined mass-scales viewfields(info.scale)
  • mask: needs to be of type MaskType which is a supertype of Array{Bool,1} or BitArray{1} with the length of the database (rows)
Mera.msum_metaprogMethod

Metaprogramming-optimized mass sum with compile-time specialization. Generates specialized code for each unit type, eliminating function call overhead.

Mera.namelistMethod
namelist(object::InfoType)
namelist(object::Dict{Any,Any})

Pretty-print the RAMSES namelist content stored in object.

For an InfoType, the namelist is read from the simulation's namelist.txt and stored in object.namelist_content. Each namelist block header and its parameters are printed to stdout.

Examples

info = getinfo(1, "path/to/sim")
namelist(info)               # show all namelist blocks
namelist(info.namelist_content)  # equivalent, passing the Dict directly
Mera.notifymeMethod

Get an email and/or Zulip notification, e.g., when your calculations are finished.

Email notification:

  • Requires the email client "mail" to be installed
  • Put a file with the name "email.txt" in your home folder that contains your email address in the first line

Zulip notification (optional):

  • Put a file with the name "zulip.txt" in your home folder with three lines:
    • Line 1: Your Zulip bot email (e.g., mybot@zulip.yourdomain.com)
    • Line 2: Your Zulip API key
    • Line 3: Your Zulip server URL (e.g., https://zulip.yourdomain.com)

Output Capture (optional):

  • capture_output: Can be a Cmd, Function, or String to capture terminal/function output
  • The captured output will be appended to your message

File Attachments (optional):

  • image_path: Single image file to attach
  • attachments: Vector of file paths to attach (multiple files)
  • attachment_folder: Path to folder - all image files (.png, .jpg, .jpeg, .gif, .svg) will be attached
  • maxattachments: Maximum number of files to attach when using attachmentfolder (default: 10)
  • maxfilesize: Maximum file size in bytes for non-image attachments (default: 25000000 ≈ 25 MB). Files larger than this are skipped with an explanatory warning (Zulip itself may enforce stricter limits – typical defaults are 25–50 MB). For images a stricter 1 MB optimization target is applied automatically to keep uploads fast and reliable; large images are resized down to <=1024px on the longest side.

Time Tracking (optional):

  • start_time: Start time for execution tracking (use time() or now())
  • include_timing: Boolean to include automatic timing information (default: false)
  • timing_details: Include detailed performance metrics (memory, allocations)

Exception Handling (optional):

  • exception_context: Exception object to include stack trace and error details
  • includestacktrace: Boolean to include full stack trace (default: true when exceptioncontext provided)
julia> notifyme()
julia> notifyme("Calculation 1 finished!")
julia> notifyme(msg="Calculation finished!", zulip_channel="alerts", zulip_topic="Run Status")
julia> notifyme(msg="Plot ready!", zulip_channel="plots", zulip_topic="Results", image_path="result.png")
julia> notifyme(msg="Multiple results!", attachments=["plot1.png", "plot2.png", "data.csv"])
julia> notifyme(msg="All plots from analysis!", attachment_folder="./plots/")
julia> notifyme(msg="Limited plots!", attachment_folder="./plots/", max_attachments=5)
julia> notifyme(msg="Large dataset results!", attachments=["data.csv"], max_file_size=50_000_000)  # 50MB limit
# Example: enforce a tighter 5 MB limit to avoid heavy uploads when on slow networks
julia> notifyme(msg="Quick summary only", attachments=["summary.log"], max_file_size=5_000_000)
# Time tracking examples
julia> start = time(); heavy_computation(); notifyme("Computation done!", start_time=start)
julia> notifyme("Analysis finished!", include_timing=true, timing_details=true)
# Exception handling examples  
julia> try
           risky_computation()
       catch e
           notifyme("Computation failed!", exception_context=e)
       end
julia> notifyme(msg="Directory listing:", capture_output=`ls`)
julia> notifyme(msg="Function output:", capture_output=() -> sum(rand(100)))
Mera.offaxis_sliceFunction
offaxis_slice(dataobject, var [, unit]; <view & range kwargs>, res=256, pxsize=nothing)
    -> (map, x, y, extent, los, up, cam_right, center, pixsize, range_unit, scale)

Off-axis slice (cutting plane): the value of var on the camera plane through the projection center, for an arbitrary line of sight (same view keywords as projection: los/inclination/azimuth/axis/theta/phi/:faceon/:edgeon/position_angle/up). Unlike a projection it does not integrate along the line of sight — each pixel is assigned the value of the cell that the plane passes through there (the cell nearest the plane wins; a coarse cell fills its footprint). This is a nearest-cell sample, hence resolution-dependent and not mass-conserving (unlike projection). Grid data only (hydro/gravity/RT).

Mera.openclose_testMethod
openclose_test(files; runs=3, N=50, levels=[1,2,4,8,16,24,32,48,64])

Measures open+close time per file across threads with adaptive units. Returns (samples, stats, unit, factor, elapsed).

Mera.optimize_mera_ioMethod
optimize_mera_io(simulation_path::String, output_num::Int; benchmark=false, quiet=false)

Automatically optimize Mera I/O settings based on your simulation characteristics.

This is the easiest way to get optimal performance - just provide your simulation path and output number, and Mera will analyze your data and apply the best settings.

Arguments

  • simulation_path: Path to your RAMSES simulation directory
  • output_num: Output number to analyze (e.g., 300)
  • benchmark=false: Set to true to run performance benchmarks for fine-tuning
  • quiet=false: Set to true to suppress output messages

Returns

  • true if optimization was successful, false otherwise

Examples

# Basic automatic optimization
optimize_mera_io("/Volumes/Storage/Simulations/mw_L10", 300)

# With benchmarking for maximum performance
optimize_mera_io("/Volumes/Storage/Simulations/mw_L10", 300, benchmark=true)

# Quiet mode for scripts
optimize_mera_io("/path/to/sim", 300, quiet=true)

What it does

  1. Analyzes your simulation (file count, sizes, AMR structure)
  2. Recommends optimal buffer size based on simulation characteristics
  3. Enables file metadata caching for faster repeat operations
  4. Optionally benchmarks different settings to find the absolute best performance

Simulation size recommendations

  • Small (< 50 files): 32KB buffer
  • Medium (50-200 files): 64KB buffer
  • Large (200-500 files): 128KB buffer
  • Very large (500-1000 files): 256KB buffer
  • Huge (> 1000 files): 512KB buffer
Mera.output_modeMethod
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 state
Mera.parse_output_numberMethod
parse_output_number(filename::String) -> Union{Int, Nothing}

Extract numerical output ID from RAMSES-style filename. Expected format: output_XXXXX.jld2 where XXXXX is zero-padded number

Examples

  • "output_00100.jld2" -> 100
  • "output_12345.jld2" -> 12345
  • "random_file.jld2" -> nothing (doesn't match pattern)
  • "output_abc.jld2" -> nothing (non-numeric)

Implementation Details

Uses regex pattern matching to ensure robust parsing Returns nothing for invalid filenames to allow filtering

Mera.patchfileMethod

Get a printout of the patchfile:

patchfile(object::InfoType)
Mera.pdfMethod
pdf(map2d::AbstractMatrix; weights=nothing, norm=:density, logbins=true, bins=60, valrange=nothing)

PDF of the values of a raw 2D array (e.g. a mock_observe image or any matrix). weights is an optional matrix of the same size (default: equal per pixel).

Mera.pdfMethod
pdf(dataobject, quantity; weight=:mass, norm=:density, logbins=true, bins=60,
    valrange=nothing, unit=:standard, mask=[false]) -> NamedTuple

Probability distribution function of a getvar quantity over the cells/particles of dataobject — works on hydro, particle, gravity, and RT data (any quantity/weight getvar supports; for signed fields like the potential :epot use logbins=false). The classic use is the density PDF — the log-normal (with a power-law high-density tail) signature of supersonic turbulence and star formation. To take the PDF of a projected 2D map (the column-density / N-PDF), pass a projection result instead (see below).

Returns (centers, edges, pdf, logbins, norm, quantity, unit, weight).

Keywords

  • weight:mass (default), :volume, or :cells/:count (number-weighted).
  • norm — how pdf is normalised:
    • :density (default) — a probability density on the binning axis (log10(quantity) when logbins, so per dex); unit area, sum(pdf .* diff(logbins ? log10.(edges) : edges)) == 1. The bin-width-independent proper PDF.
    • :probability — per-bin probability mass, sum(pdf) == 1.
    • :peak — shape only, scaled so maximum(pdf) == 1.
    • :count (:none) — raw weighted counts, sum(pdf) == total weight.
  • logbins — log-spaced bins over log10(quantity) (default; quantity must be > 0).
  • bins — number of bins; valrange(min, max) of the quantity (default: data range).
  • unit — unit of quantity; mask — restrict to selected cells/particles.
P  = pdf(gas, :rho)                          # mass-weighted density PDF (area = 1)
Pv = pdf(gas, :rho; weight=:volume)          # volume-weighted (turbulence log-normal)
Pp = pdf(gas, :rho; norm=:probability)       # bins sum to 1
Pk = pdf(gas, :rho; norm=:peak)              # peak = 1 (compare shapes)
# plot: lines(log10.(P.centers), P.pdf)
Note

pdf is also exported by Distributions.jl; if you using both, call Mera.pdf.

Mera.pdfMethod
pdf(m::DataMapsType, var; weight=:area, norm=:density, logbins=true, bins=60, valrange=nothing)

PDF of the pixel values of a projected 2D map m.maps[var] (a projection result). With var=:sd and the default area weighting this is the column-density PDF (N-PDF) — a standard observational diagnostic. weight is :area (every pixel counts equally), :value (weight by the pixel value), or another map key Symbol in m.maps (weight pixel-by-pixel by that map). Other keywords are as for the cell/particle method.

Mera.perform_sanity_checksMethod
perform_sanity_checks(gas_data) → Bool

Execute comprehensive data quality validation with 5 critical checks.

Validates hydro simulation data quality and completeness before benchmark execution. Ensures reliable benchmark results by detecting common data issues that could affect projection performance measurements.

Validation Checks

  1. Cell Count Validation: Minimum 1000 cells for statistical reliability
  2. Required Variables: Presence of essential hydro variables (:ρ, :cx, :cy, :cz)
  3. Physical Density: Positive density values within reasonable ranges
  4. Coordinate Extent: Non-degenerate spatial coverage for meaningful projections
  5. AMR Level Consistency: Valid refinement level range and distribution

Quality Threshold

Returns true if ≥80% of checks pass (4/5), indicating acceptable data quality for benchmark execution. Failed checks are reported with specific guidance.

Example

if perform_sanity_checks(gas_data)
    println("✅ Data quality sufficient for benchmarking")
    results = benchmark_projection_hydro(gas_data, [1,2,4,8], 5, "test")
else
    error("❌ Data quality issues detected - resolve before benchmarking")
end

Returns

  • true: Data passes quality threshold (≥80% checks successful)
  • false: Data fails quality threshold, benchmarking not recommended
Mera.phaseFunction
phase(m::DataMapsType, xvar, yvar [, cvar]; weight=:none, nbins=(100,100), …) -> NamedTuple

2D phase diagram from a projected map — bin two map variables against each other, weighted by :none/:area or another map key, optionally colouring by the weighted mean of a third map cvar.

Returns

The same fields as the data phase method (xedges, yedges, H, the cstat grids when a cvar is given, and fraction/pdf when normalized), with source=:map.

Mera.phaseFunction
phase(dataobject, xvar, yvar [, cvar]; weight=:mass, nbins=(100,100), xrange=nothing,
      yrange=nothing, xscale=:linear, yscale=:linear, xunit=:standard, yunit=:standard,
      cunit=:standard, center=[:bc], center_unit=:standard, mask=[false]) -> NamedTuple

2D phase diagram — the summed weight in bins of (xvar, yvar) (e.g. a mass-weighted density–temperature diagram, phase(gas, :rho, :T; xscale=:log, yscale=:log)). With a third field cvar, also returns the per-bin weighted mean of cvar. H[i,j] is the total weight in x-bin i, y-bin j. normalize=:sum/:pdf adds fraction/pdf (2-D). With cvar, cstat selects a richer per-bin reduction of cvar in addition to mean: :std, :median, :min, :max, :full (all four), or a function f(cview, wview) (→ custom). Any non-:mean cstat also returns a per-bin weighted quantiles array (nbx × nby × length(quantiles)) at the quantiles levels (with qlevels).

Returns

A NamedTuple with xedges, yedges (bin edges), H (the nbx × nby summed-weight grid), xvar/yvar, weight, xunit/yunit, and source=:data. With normalize, also fraction/pdf. With a cvar: mean (and, for a non-:mean cstat, the corresponding std/median/min/max/ quantiles/custom grids), plus cvar/cunit.

Mera.plot_resultsMethod
plot_results(res; bins=30) -> Makie.Figure

Visualise a run_benchmark result as a 3-panel I/O figure: IOPS scaling vs threads, the per-file throughput distribution, and file open/close time vs threads. Needs a Makie backend (using CairoMakie or GLMakie); the Figure is returned, so save it with Makie.save("io.png", fig).

using Mera, CairoMakie
res = run_benchmark("/path/to/output_00250/"; runs=20)   # benchmark your own data folder
fig = plot_results(res)                                   # no download needed — built in
Makie.save("io_benchmark.png", fig)
Mera.position_velocityMethod
position_velocity(dataobject; <view kwargs>, offset_axis=:right, nbins=256,
                  offset_unit=:kpc, v_unit=:km_s, center=[:bc], range_unit=:standard,
                  mask=[false]) -> NamedTuple

Off-axis position–velocity (PV) diagram: a 2D mass histogram in (in-plane offset, line-of-sight velocity). Returns a NamedTuple (offset, velocity, pv, offset_unit, v_unit, los) where offset/velocity are the bin edges and pv is the nbins×nbins mass map (M⊙ in code mass units).

The view is set with the same keywords as projection (los, inclination/azimuth/axis, theta/phi, direction=:faceon/:edgeon, position_angle). offset_axis selects which in-plane camera axis is the position coordinate (:right = image x, or :up = image y).

Mera.preprangesMethod

cuboid ranges convert given ranges and print overview on screen used for gethydro, getparticles, getgravity, getclumps..., subregions...

Mera.preprangesMethod

cylinder ranges (height != 0.), sphere ranges (height==0.) convert given ranges + radius and print overview on screen used for subregions...

Mera.previewMethod
preview(plan::ReportPlan; io=stdout) -> ReportPlan

Zero-I/O dry run: print the read level, predicted cells, and an estimated per-card and total runtime, without reading any data. Returns the plan unchanged so it can be piped into report.

Mera.printtablememoryMethod
printtablememory(data, verbose::Bool)

Print memory usage information for a data table when verbose mode is enabled.

Arguments

  • data: Data object whose memory usage should be displayed
  • verbose::Bool: Whether to display the memory information

Examples

# Display memory usage for a data table
printtablememory(hydro_data, true)
Mera.printtimeFunction
printtime(text::String="", verbose::Bool=verbose_mode)

Print a Mera timestamp with optional text message to the screen when verbose mode is enabled.

Arguments

  • text::String="": Optional text message to display before the timestamp
  • verbose::Bool=verbose_mode: Control output display (uses global verbose_mode by default)

Examples

# Print timestamp with default message
printtime()

# Print timestamp with custom message
printtime("Starting calculation")

# Override verbose setting
printtime("Debug info", true)
Mera.profileFunction
profile(dataobject, xvar [, yvar]; weight=:mass, nbins=50, xrange=nothing, scale=:linear,
        edges=nothing, geometry=:none, cumulative=:none, normalize=:none, statistic=nothing,
        xunit=:standard, unit=:standard, center=[:bc], center_unit=:standard,
        quantiles=[0.16, 0.5, 0.84], mask=[false],
        bootstrap=0, ci=:percentile, confidence_level=0.95, bootstrap_seed=20240601) -> NamedTuple

1D profile from 3D data. Bin by xvar and reduce yvar (or the weight itself) per bin. Any getvar fields, for hydro / gravity / RT / particle data; the classic use is a radial profile with xvar a length (:r_cylinder, :r_sphere, :z, …) about a physical center. (Clumps expose only their own catalogue columns — they have no :mass/:rho/:r_sphere getvar field — so radial/mass profiles are not available for clump data.)

  • weight:mass, :volume, :none (equal weights), or any field; should be non-negative (negative summed weights make the weighted mean/std/quantiles ill-defined → NaN). Mass/volume weighting works for any data type that has that field (:volume is grid-only; particles use :mass).
  • center/center_unit — reference point and its unit (e.g. center=[24,24,24], center_unit=:kpc). range_unit is accepted as a back-compat alias of center_unit.
  • xrange=(lo,hi) (end point) in xunit (the binning axis can be any quantity, so its unit is xunit, not center_unit/range_unit — unlike the spatial xrange of projection). xunit/unit set the x-axis / yvar field units.
  • scale:linear (default), :log (log-spaced bins), or :equal (quantile-spaced adaptive bins so every bin holds ~the same number of points — robust for sparse outer radii / noisy data).
  • bootstrap=N (>0) — also return bootstrap confidence intervals for the per-bin mean and median by resampling each bin N times (default off). ci selects the interval: :percentile (default), :basic, or :bca (bias-corrected & accelerated). confidence_level (default 0.95) and a fixed bootstrap_seed (deterministic). Adds mean_ci/median_ci (nbins×2: lower, upper) + median_se. Cost is O(bootstrap·N_bin) per bin (:bca adds an O(N_bin²) jackknife) — meant for modest counts.
  • quantiles — percentile levels for the per-bin weighted quantiles (default 16/50/84%).
  • edges — an explicit vector of bin edges (overrides nbins/xrange/scale); given in xunit.
  • geometry:spherical (shell volume 4/3·π·Δr³) or :cylindrical (annulus area π·Δr²) adds shell_volume and a density = sum / shell_volume (e.g. a radial ρ(r) or surface density), in weight-unit per xunit³ (xunit²). Pair with xvar=:r_sphere/:r_cylinder.
  • cumulative:forward (low→high) or :reverse adds cumsum/cumcount (e.g. enclosed mass M(<r)).
  • normalize:sum adds fraction = sum/Σsum (bins sum to 1); :pdf also adds pdf = fraction/Δedge (integral = 1).
  • statistic — a function applied per bin (called as f(yview, wview) if it accepts weights, else f(yview)) returning a scalar; result in custom. Needs yvar.

yvar may be a vector of fields ([:T, :rho]): the data is binned once and each field is reduced in the same pass — the per-field statistics are returned under fields (e.g. p.fields[:T].mean) with the order in yvars.

Returns x (centres), edges, count, sum (Σ weight), sumw2 (Σ weight²); with a single yvar also weighted mean, std, sem (standard error on the mean via Kish neff), min, max, median, a quantiles matrix (nbins × length(qlevels)), and the weighted shape moments skewness and kurtosis (excess kurtosis — 0 for a Gaussian). (bootstrap adds the CI fields.)

Mera.profileMethod
profile(m::DataMapsType, var; xvar=:r, weight=:none, nbins=50, xrange=nothing, scale=:linear,
        edges=nothing, geometry=:none, cumulative=:none, statistic=nothing,
        xunit=:standard, center=nothing, center_unit=:standard, quantiles=[0.16,0.5,0.84])
    -> NamedTuple

1D profile from a projected 2D map (a projection result). Bin the pixels of m.maps[var] by xvar and reduce per bin with the same statistics as the data method. xvar is

  • :r — image-plane radius from center (a surface-brightness / Σ(R) profile),
  • :x / :y — an image-plane coordinate, or
  • another map key — bin one map against another (any map vs any map).

weight is :none/:area (equal pixels) or another map key (e.g. weight=:sd for a column-weighted profile of :vlos). For the :r/:x/:y cases center (default: the map centre) is in center_unit (range_unit accepted as an alias) while xrange is in xunit (the radius is converted from code units via the map's scale). edges, geometry (:cylindrical annulus area for a 2-D map), cumulative and statistic work as in the data method.

Returns

The same per-bin statistic fields as the data profile method, plus var (the binned map variable), xvar, weight, xunit, unit (the mapped variable's unit, from the projection), and source=:map.

Mera.profile3dFunction
profile3d(dataobject, xvar, yvar, zvar [, cvar]; weight=:mass, nbins=(50,50,50),
          xrange=nothing, yrange=nothing, zrange=nothing, xscale=:linear, yscale=:linear,
          zscale=:linear, xunit=:standard, yunit=:standard, zunit=:standard, cunit=:standard,
          center=[:bc], center_unit=:standard, normalize=:none, mask=[false]) -> NamedTuple

3D profile — the summed weight in bins of three fields (xvar, yvar, zvar), the 3-D generalization of phase. H[i,j,k] is the total weight in the (i,j,k) cell, and sum(H) is the total weight (e.g. a ρ–T–Z mass cube). With a fourth field cvar, also returns the per-bin weighted mean of cvar. normalize=:sum adds fraction = H/ΣH; :pdf also adds pdf (÷ the 3-D cell volume, so the integral is 1). Each axis takes its own range/scale/unit, and nbins is an integer or a 3-tuple. Marginalizing one axis (sum(H; dims=3)) recovers the corresponding phase.

Returns xedges, yedges, zedges, H (and mean with cvar; fraction/pdf if normalized).

Mera.profiletimeseriesFunction
profiletimeseries(loadfn, outputs, xvar [, yvar]; field=nothing, time_unit=:Myr, kwargs...)
    -> NamedTuple

Stack a profile across snapshots into a (nbins × n_snapshots) matrix — a radius-vs-time map (e.g. the evolution of a rotation/density/temperature profile). loadfn(output) returns a loaded data object for that snapshot, e.g. out -> gethydro(getinfo(out, path), verbose=false). For each output, profile(loadfn(output), xvar, yvar; kwargs...) is computed and the field field (default :mean with a yvar, else :sum) is stacked as a column; the snapshot time comes from gettime in time_unit.

For a vector yvar ([:rho, :T]) the per-field statistics live under pr.fields[field], so pass field=(:fieldname, :stat) (e.g. field=(:rho, :mean)) to pick which field/statistic to stack; the default is the first field's :mean.

Pass a fixed radius axis (xrange+nbins or explicit edges) so the columns align — otherwise the per-snapshot bin counts differ and an error is raised. Extra kwargs are forwarded to profile.

Returns x (bin centres), edges, t (times in time_unit), outputs, M (nbins × n_snap matrix of field) and field.

Mera.projectFunction
project(data, var [, unit]; res=auto, kwargs...)                      # already-loaded hydro/particles
project(info::InfoType, var [, unit]; vars=auto, lmax=…, kwargs...)   # load hydro, then project
project(path::AbstractString, output::Integer, var [, unit]; kwargs...)  # getinfo + load + project

One-call projection. A high-level convenience that loads the data (when given an InfoType or a path+output) and projects in a single call — the ergonomic equivalent of yt.ProjectionPlot(ds, "z", field).

  • Smart resolution — if res is not given it defaults to 2^lmax capped at 1024, so a deep AMR run doesn't silently allocate an enormous map (pass res= to override; a note is printed when capped).
  • Loading — reads the full hydro state by default (fast); restrict with vars=[:rho] if you know exactly what the projection (and its weighting / view) needs.
  • All other keywords (direction, los, center, range_unit, weight, mode, pxsize, …) are forwarded to projection; the return value is the same map object.
Mera.projectionMethod

Combined Hydro + Gravity Projection Functions

These convenience overloads accept both HydroDataType and GravDataType arguments, enabling access to gravity-derived quantities while maintaining hydro mass weighting.

# Single variable projection
projection(hydro, gravity, :epot)                    # Gravity potential with hydro weighting
projection(hydro, gravity, :rho, :g_cm3)            # Hydro density (works as before)

# Multiple variables with same units  
projection(hydro, gravity, [:epot, :rho], :standard) # Mixed gravity/hydro variables

# Multiple variables with different units
projection(hydro, gravity, [:epot, :rho], [:erg, :g_cm3]) # Custom units per variable
Mera.projectionMethod

Project variables or derived quantities from the particle-dataset:

  • projection to a grid related to a given level
  • overview the list of predefined quantities with: projection()
  • select variable(s) and their unit(s)
  • limit to a maximum range
  • give the spatial center (with units) of the data within the box (relevant e.g. for radius dependency)
  • relate the coordinates to a direction (x,y,z) — or project along an arbitrary off-axis line of sight via los=[..], spherical angles theta/phi (angle_unit=:rad/:deg), or the disk presets direction=:faceon/:edgeon (line of sight from the particle angular momentum). The off-axis camera basis is stored on the returned map (.los, .up, .cam_right, .center; .direction==:offaxis). Point particles have no footprint, so binning=:cic (default) / :ngp apply (:overlap and :exact fall back to :cic). See the hydro projection docstring for details.
  • select between mass (default) and volume weighting
  • pass a mask to exclude elements (cells/particles/...) from the calculation
  • toggle verbose mode
  • toggle progress bar
  • pass a struct with arguments (myargs)
projection(   dataobject::PartDataType, vars::Array{Symbol,1};
                units::Array{Symbol,1}=[:standard],
                lmax::Real=dataobject.lmax,
                res::Union{Real, Missing}=missing,
                pxsize::Array{<:Any,1}=[missing, missing],
                mask=[false],
                direction::Symbol=:z,
                weighting::Symbol=:mass,
                xrange::Array{<:Any,1}=[missing, missing],
                yrange::Array{<:Any,1}=[missing, missing],
                zrange::Array{<:Any,1}=[missing, missing],
                center::Array{<:Any,1}=[0., 0., 0.],
                range_unit::Symbol=:standard,
                data_center::Array{<:Any,1}=[missing, missing, missing],
                data_center_unit::Symbol=:standard,
                ref_time::Real=dataobject.info.time,
                verbose::Bool=true,
                show_progress::Bool=true,
                myargs::ArgumentsType=ArgumentsType()  )

return PartMapsType

Arguments

Required:

  • dataobject: needs to be of type: "PartDataType"
  • var(s): select a variable from the database or a predefined quantity (see field: info, function projection(), dataobject.data)

Predefined/Optional Keywords:

  • unit(s): return the variable in given units
  • pxsize`: creates maps with the given pixel size in physical/code units (dominates over: res, lmax) : pxsize=[physical size (Number), physical unit (Symbol)]
  • res create maps with the given pixel number for each deminsion; if res not given by user -> lmax is selected; (pixel number is related to the full boxsize)
  • lmax: create maps with 2^lmax pixels for each dimension
  • xrange: the range between [xmin, xmax] in units given by argument range_unit and relative to the given center; zero length for xmin=xmax=0. is converted to maximum possible length
  • yrange: the range between [ymin, ymax] in units given by argument range_unit and relative to the given center; zero length for ymin=ymax=0. is converted to maximum possible length
  • zrange: the range between [zmin, zmax] in units given by argument range_unit and relative to the given center; zero length for zmin=zmax=0. is converted to maximum possible length
  • range_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 argument range_unit; by default [0., 0., 0.]; the box-center can be selected by e.g. [:bc], [:boxcenter], [value, :bc, :bc], etc..
  • weighting: select between :mass weighting (default) and :volume weighting
  • data_center: to calculate the data relative to the datacenter; in units given by argument `datacenterunit`; by default the argument datacenter = center ;
  • data_center_unit: :standard (code units), :Mpc, :kpc, :pc, :mpc, :ly, :au , :km, :cm (of typye Symbol) ..etc. ; see for defined length-scales viewfields(info.scale)
  • direction: axis-aligned :x, :y, :z, or the disk presets :faceon/:edgeon
  • off-axis view (any line of sight): inclination/azimuth (+ axis=:z/:angmom/vector), los=[lx,ly,lz], or theta/phi; position_angle rolls the image; angle_unit=:deg (default) or :rad. See the hydro projection docstring for the full description; for point particles binning=:overlap falls back to :cic.
  • mask: needs to be of type MaskType which is a supertype of Array{Bool,1} or BitArray{1} with the length of the database (rows)
  • ref_time: the age quantity relative to a given time (code_units); default relative to the loaded snapshot time
  • show_progress: print progress bar on screen
  • myargs: 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

Defined Methods - function defined for different arguments

  • projection( dataobject::PartDataType, var::Symbol; ...) # one given variable
  • projection( dataobject::PartDataType, var::Symbol, unit::Symbol; ...) # one given variable with its unit
  • projection( dataobject::PartDataType, vars::Array{Symbol,1}; ...) # several given variables -> array needed
  • projection( dataobject::PartDataType, vars::Array{Symbol,1}, units::Array{Symbol,1}; ...) # several given variables and their corresponding units -> both arrays
  • projection( dataobject::PartDataType, vars::Array{Symbol,1}, unit::Symbol; ...) # several given variables that have the same unit -> array for the variables and a single Symbol for the unit

Examples

...

Mera.projectionMethod

AMR Hydro Projection Functions

This module provides high-performance functionality for projecting AMR (Adaptive Mesh Refinement) hydrodynamic simulation data onto regular 2D grids. The projection engine handles multi-level AMR data with proper coordinate transformations, geometric mapping, and optimized parallel processing.

Architecture Overview

The projection system uses variable-based parallelization where each thread processes one variable across all AMR levels. This approach eliminates the costly combining phase that traditional chunked parallelization requires, resulting in significant performance improvements.

Cosmological runs

For a cosmological simulation, lengths, extents and (surface) densities here are in the proper (physical) frame at the snapshot's scale factor aexp (RAMSES unit_l/unit_d are proper). Convert to comoving with the proper_to_comoving_* helpers (× or ÷ powers of aexp). The cosmology-aware derived gas field :overdensity (= ρ/ρ̄_b − 1) can be projected like any other hydro variable.

Key Design Principles:

  • Thread Safety: No shared mutable state between threads
  • Memory Efficiency: Direct allocation without memory pools
  • Performance: Variable-based parallelization eliminates combining overhead
  • Conservation: Mass-preserving cell-to-pixel mapping
  • Flexibility: Support for multiple projection directions and coordinate systems

Core Functionality

Data Projection Features:

  • Multi-resolution mapping: Projects AMR cells from different refinement levels onto uniform grids
  • Variable projection: Supports density, surface density, velocity, pressure, temperature and derived quantities
  • Flexible grid sizing: Custom resolution, pixel size, or automatic sizing based on AMR levels
  • Spatial filtering: Range-based data selection in x, y, z dimensions with thin slice support
  • Weighting schemes: Mass weighting (default), volume weighting, or custom weighting functions
  • Direction control: Project along x, y, or z directions with proper coordinate remapping

AMR-Specific Features:

  • Conservative mapping: Mass-conserving cell-to-pixel mapping with geometric overlap calculations
  • Level-specific processing: Individual handling of each AMR refinement level for accuracy
  • Boundary handling: Robust treatment of cell boundaries and partial overlaps
  • Coordinate transformations: Automatic handling of different AMR coordinate systems

Main Projection Function

Create high-performance 2D projections of AMR hydro data with full control over resolution, spatial ranges, and processing options. This function automatically selects between sequential and variable-based parallel processing based on data characteristics.

Function Signature

projection(dataobject::HydroDataType, vars::Array{Symbol,1};
           units::Array{Symbol,1}=[:standard],
           lmax::Real=dataobject.lmax,
           res::Union{Real, Missing}=missing,
           pxsize::Array{<:Any,1}=[missing, missing],
           mask::Union{Vector{Bool}, MaskType}=[false],
           direction::Symbol=:z,
           weighting::Array{<:Any,1}=[:mass, missing],
           mode::Symbol=:standard,
           xrange::Array{<:Any,1}=[missing, missing],
           yrange::Array{<:Any,1}=[missing, missing],
           zrange::Array{<:Any,1}=[missing, missing],
           center::Array{<:Any,1}=[0., 0., 0.],
           range_unit::Symbol=:standard,
           data_center::Array{<:Any,1}=[missing, missing, missing],
           data_center_unit::Symbol=:standard,
           verbose::Bool=true,
           show_progress::Bool=true,
           verbose_threads::Bool=false,
           myargs::ArgumentsType=ArgumentsType())

return AMRMapsType

Arguments

Required Parameters:

  • dataobject::HydroDataType: AMR hydro simulation data loaded by Mera.jl
    • Must contain spatial coordinates and hydro variables
    • Supports RAMSES, ENZO, and other AMR formats
  • vars::Array{Symbol,1}: Variables to project (e.g., [:rho, :vx, :vy] or [:sd])
    • Multiple variables trigger automatic variable-based parallelization
    • Single variables use optimized sequential processing

Grid Resolution Control:

  • res::Union{Real, Missing}: Pixel count per dimension (e.g., res=512 → 512×512 grid)
    • Higher values increase precision but require more memory
    • Recommended: 256-1024 for most applications
  • lmax::Real: Use 2^lmax pixels when res not specified (default: dataobject.lmax)
    • Automatically matches finest AMR level resolution
  • pxsize::Array: Physical pixel size [value, unit] (overrides res/lmax)
    • Direct control over spatial resolution

Spatial Range Control:

  • xrange/yrange/zrange::Array: Spatial bounds [min, max] relative to center
    • Define the physical region to project (e.g., [-10, 10] for ±10 units)
    • Units controlled by range_unit parameter
  • center::Array: Projection center coordinates (use [:bc] for box center)
    • Can be physical coordinates or special values like [:bc], [:com]
  • range_unit::Symbol: Units for ranges/center (:kpc, :Mpc, :pc, :standard, etc.)
    • Ensures consistent spatial scaling across different simulations
  • direction::Symbol: Axis-aligned projection direction (:x, :y, :z)
    • Determines which spatial dimension is integrated over
    • Also accepts the disk presets :faceon / :edgeon (off-axis, see below)

Off-axis projection (arbitrary line of sight):

Give any of the following to project along an arbitrary line of sight instead of an axis. When none are given, the axis-aligned path above runs unchanged. Angles are in degrees by default (angle_unit=:rad to switch).

  • inclination, azimuth (user-oriented; azimuth alias position_angle): tilt the view away from a reference axis by inclination (0°⇒down the axis, 90°⇒⟂ to it) and rotate around it by azimuth.

  • axis: reference axis for inclination/azimuth. Default :z (box vertical — assumes nothing about the contents, good for clouds/filaments/cosmic web). :angmom measures from the object's own angular momentum L (then 0°=face-on, 90°=edge-on); or give :x/:y/a 3-vector. NOTE: :angmom (and :faceon/:edgeon) are only a meaningful "disk normal" for a rotating disk, and L is computed about center — so center on the object (its centre of mass) for L to be the true spin; off-centre it is contaminated by bulk motion.

  • direction=:faceon/:edgeon: shortcuts for inclination=0/90 with axis=:angmom.

  • los::Vector: explicit line-of-sight (viewing) direction, e.g. los=[1,1,1] (need not be normalized)

  • theta, phi: spherical angles about the box axes; los=[sinθcosφ, sinθsinφ, cosθ].

  • up::Vector: optional camera up-vector (default: auto; the reference axis kept upright)

  • angle_unit::Symbol: :deg (default) or :rad

  • binning::Symbol: how rotated cells are deposited onto the camera plane —

    • :overlap (default) — per-cell footprint supersampling (ns = ceil(cellsize/pixel) sub-points per cube axis, capped at nmax); AMR-aligned (no moiré, no holes), converges to :exact, and is usually faster than :exact. Cells coarser than the nmax cap stay mildly blocky.
    • :exact — analytic box-spline footprint: integrates the line-of-sight column (chord length through the cube) over each pixel exactly; no supersampling cap, the reference for fidelity.
    • :cic — fast preview, bilinear deposit of cell centres; speckles/moiré on coarse AMR cells
    • :ngp — fast preview, nearest-pixel deposit (sharp)
  • nmax::Int: :overlap supersampling cap (default 64) — max sub-points per cube axis. Raise for fewer artifacts on very coarse cells (slower, ∝ nmax³), lower for speed.

    All are mass-conserving. Off-axis currently supports the standard hydro/RT fields and :sd/:mass; map-only variables (:r_cylinder, , velocity dispersions) require an axis direction.

Data Processing Options:

  • weighting::Array: Variable for weighting [quantity, unit] (default: [:mass])
    • Controls how cell values are averaged: mass-weighted, volume-weighted, etc.
    • e.g. [:volume] for a volume-weighted average, or [:mass] (default)
  • mode::Symbol: Processing mode (:standard or :sum)
    • :standard → weighted averages (typical for intensive quantities)
    • :sum → accumulative totals (for extensive quantities like mass)
  • mask::Union{Vector{Bool}, MaskType}: Boolean mask to exclude cells
    • Filter out unwanted regions or apply custom selection criteria
  • units::Array{Symbol,1}: Output units for projected variables
    • Convert results to desired physical units automatically

Advanced Options:

  • data_center/data_center_unit: Alternative center for data calculations
    • When different from projection center (useful for coordinate transformations)
  • verbose::Bool: Print diagnostic information during processing (default: true)
    • Shows progress, memory usage, and basic threading information
  • show_progress::Bool: Display progress bar for level-by-level processing (default: true)
    • Visual feedback for long-running projections
  • verbose_threads::Bool: Show detailed multithreading diagnostics (default: false)
    • Enable for debugging parallel performance or thread behavior
  • myargs::ArgumentsType: Struct to pass multiple arguments simultaneously
    • Convenient for passing common parameter sets

Method Variants

The projection function supports multiple calling patterns for convenience:

# Single variable projection
projection(dataobject, :rho)                    # Density with default settings
projection(dataobject, :rho, unit=:g_cm3)      # Density in specific units

# Multiple variables with same units  
projection(dataobject, [:v, :vx, :vy], :km_s) # Multiple vars, single unit

# Multiple variables with different units
projection(dataobject, [:rho, :sd], [:g_cm3, :Msol_pc2]) # Different units per variable

# Surface density projection (special handling)
projection(dataobject, :sd, :Msol_pc2)         # Surface density in solar masses per pc²

Usage Examples

Basic Density Projection

# Simple density map of full simulation box (sequential processing)
density_map = projection(gas, :rho, unit=:g_cm3, res=512)

# High resolution central region with optimal settings
density_map = projection(gas, :rho, unit=:g_cm3, 
                        xrange=[-10, 10], yrange=[-10, 10], 
                        center=[:bc], range_unit=:kpc, res=1024)

Multi-Variable Analysis (Parallel Processing)

# Velocity field analysis (automatic variable-based parallelization)
velocity_maps = projection(gas, [:vx, :vy, :vz], unit=:km_s,
                          direction=:z, res=512)
# Output: 🧵 Using parallel processing with 3 threads (one per variable)

# Combined density and velocity (optimal parallel performance)
hydro_maps = projection(gas, [:rho, :vx, :vy], [:g_cm3, :km_s, :km_s],
                       xrange=[-5, 5], yrange=[-5, 5], 
                       center=[:bc], range_unit=:kpc)
# Output: ✅ Parallel projection completed successfully

Advanced AMR Projections

# High-precision thin slice (demonstrates AMR coordinate handling)
thin_slice = projection(gas, :sd, :Msol_pc2,
                       zrange=[0.49, 0.51], center=[:bc],
                       range_unit=:standard, direction=:z, res=1024)

# Volume-weighted projection for physical accuracy
volume_proj = projection(gas, :rho, 
                        weighting=[:volume, :cm3],
                        mode=:sum, res=512)

# Large multi-variable projection (optimal parallel performance)
comprehensive = projection(gas, [:rho, :vx, :vy, :vz, :cs], 
                          [:g_cm3, :km_s, :km_s, :km_s, :km_s],
                          res=2048, verbose_threads=true)
# Shows detailed threading diagnostics for performance analysis

Direction-Specific Projections

# X-direction projection (YZ plane) - parallel processing for multiple variables
x_proj = projection(gas, [:rho, :vx], [:g_cm3, :km_s],
                   direction=:x, yrange=[-10, 10], zrange=[-5, 5],
                   center=[:bc], range_unit=:kpc)

# Y-direction projection (XZ plane) - sequential processing for single variable
y_proj = projection(gas, :sd, :Msol_pc2,
                   direction=:y, xrange=[-20, 20], zrange=[-10, 10],
                   center=[:bc], range_unit=:kpc)

Threading Control and Performance Monitoring

# Basic thread information (always shown with verbose=true)
density_map = projection(gas, :rho, :g_cm3, res=512)
# Output: Available threads: 8
#         Requested max_threads: 8
#         Processing mode: Sequential (single variable)

# Detailed threading diagnostics for performance analysis
multi_var = projection(gas, [:rho, :vx, :vy, :vz], res=1024, 
                      verbose_threads=true)
# Output: Available threads: 8
#         Requested max_threads: 8
#         Processing mode: Variable-based parallel (4 threads)
#         🧵 Thread allocation: rho→T1, vx→T2, vy→T3, vz→T4
#         ✅ Parallel projection completed successfully
#         Performance: 2.1M cells/sec, Efficiency: 91.7%
#
# Note: verbose_threads=true shows detailed per-thread performance metrics

Hide all output with verbose=false

densitymap = projection(gas, :rho, :gcm3, res=512, verbose=false) # No threading output at all


#### Physical Pixel Size Control (pxsize)

julia

High-resolution projection with 10 pc pixels

highres = projection(gas, :rho, :gcm3, pxsize=[10., :pc], xrange=[-1, 1], yrange=[-1, 1], center=[:bc], range_unit=:kpc)

Ultra-high resolution with 1 pc pixels for detailed structure

ultrahigh = projection(gas, :sd, :Msolpc2, pxsize=[1., :pc], xrange=[-500, 500], yrange=[-500, 500], center=[:bc], range_unit=:pc)

Large-scale map with 100 pc pixels for overview

overview = projection(gas, [:rho, :temperature], [:gcm3, :K], pxsize=[100., :pc], xrange=[-10, 10], yrange=[-10, 10], center=[:bc], rangeunit=:kpc)

Custom units: 0.1 kpc (100 pc) pixels

customscale = projection(gas, :vx, :kms, pxsize=[0.1, :kpc], xrange=[-5, 5], yrange=[-5, 5], center=[:bc], range_unit=:kpc)

Very fine scale: sub-parsec resolution

finedetail = projection(gas, :density, :gcm3, pxsize=[0.1, :pc], xrange=[-10, 10], yrange=[-10, 10], center=[:bc], range_unit=:pc)


### Return Value

Returns `AMRMapsType` (alias: `HydroMapsType`) containing:
- **`.maps`**: Dictionary of projected variable maps (2D arrays)
- **`.extent`**: Physical extent of projection [xmin, xmax, ymin, ymax]
- **`.pixsize`**: Physical size of each pixel
- **`.lmax_projected`**: Maximum AMR level included in projection
- **`.ranges`**: Normalized coordinate ranges used
- **`.center`**: Physical center coordinates of projection

### Radiative transfer (RT) projections

The same `projection` function accepts an `RtDataType` object (`rt = getrt(info)`)
and shares the AMR engine above. Two RT-specific behaviours apply:

- **Default weighting is `:volume`** (not `:mass`): RT fields carry no cell mass, so
  a mass weight is meaningless. Passing `weighting=[:mass]` is silently promoted to
  `[:volume]`. Override explicitly with e.g. `weighting=[:Np1]` to flux-weight by the
  photon density.
- **`mode=:standard`** (default) gives the **volume-weighted average** of the field
  along the line of sight (per pixel). **`mode=:sum`** gives the volume-weighted
  **sum** per pixel — i.e. Σ q·V_cell over the column, so for `:Np1` (a number
  density) it is proportional to the **total photon count** projected onto each
  pixel (the whole map sums to the box photon number), not the column density
  ∫q dz. For a mass-style **column density** use a `HydroDataType` with `:sd`
  (which divides by the pixel area); RT fields have no `:sd` analogue.

Typical RT maps:

julia rt = getrt(info) gas = gethydro(info)

Photon-count map of group 1 (volume-weighted sum per pixel)

npsum = projection(rt, :Np1, mode=:sum, center=[:bc], rangeunit=:kpc)

Reduced-flux map (beam vs. isotropic), volume-weighted average

fmap = projection(rt, :reducedflux1, center=[:bc])

Mock recombination-line emission map (∝ ∫ n_HII² dz) — a HYDRO quantity

em = projection(gas, :emrecomb, mode=:sum, center=[:bc], rangeunit=:kpc)

Ionization map xHII (hydro passive scalar located via the RT descriptor)

xmap = projection(gas, :xHII, center=[:bc])


RT photon fields and the hydro ionization state live on **separate** objects; project
each on its own object (analogous to gravity vs. hydro). Use `getvar(rt, …)` /
`getvar(gas, …)` for the per-cell quantities documented under `getvar`.

Off-axis projections:

julia gas = gethydro(info)

Look along an arbitrary line of sight (fast CIC preview)

m = projection(gas, :sd, :Msolpc2, los=[1,1,1], center=[:bc], rangeunit=:kpc)

Same view, accurate footprint-correct deposit (parallel; for final figures)

m = projection(gas, :sd, :Msol_pc2, los=[1,1,1], binning=:overlap, center=[:bc])

Spherical angles instead of a vector (degrees)

m = projection(gas, :sd, theta=60, phi=30, angle_unit=:deg, center=[:bc])

Disk seen face-on / edge-on (line of sight from the gas angular momentum)

fo = projection(gas, :sd, direction=:faceon, center=[:bc], rangeunit=:kpc) eo = projection(gas, :sd, direction=:edgeon, center=[:bc], rangeunit=:kpc) ```

The off-axis camera basis is stored on the returned map (m.los, m.up, m.cam_right, m.center; m.direction == :offaxis). The cell→pixel deposit uses the standard nearest-grid-point / cloud-in-cell assignment scheme (Hockney & Eastwood 1988, Computer Simulation Using Particles); :overlap extends CIC with per-cell footprint supersampling. All deposits conserve the projected total to machine precision.

Mera.projectionMethod
projection()

Display an overview of variable symbols accepted by the projection interface for hydro and particle data as well as derived quantities. This zero-argument form is a helper to discover valid field names before calling one of the many method overloads such as:

projection(hydro::HydroDataType, :rho; direction=:z, res=256)
projection(particles::PartDataType, [:mass, :vz]; weighting=:mass)

Actual data projections are implemented in specialized method definitions located in projection_hydro.jl and projection_particles.jl (and gravity combo variants). Those methods accept keywords like direction, res, xrange, yrange, zrange, center, weighting, show_progress, and unit selection arguments. This summary call prints the canonical / alias variable names and returns nothing.

Mera.proper_to_comoving_densityMethod
proper_to_comoving_density(info, density_proper) -> Float64

Convert a proper mass density at the snapshot to comoving (comoving = proper * aexp^3). Identity for non-cosmological runs.

Mera.proper_to_comoving_lengthMethod
proper_to_comoving_length(info, length_proper) -> Float64

Convert a proper length at the snapshot to comoving (comoving = proper / aexp). Identity for non-cosmological runs.

Mera.provenanceMethod
provenance(x) -> Provenance

Build a Provenance record from an InfoType or from any result that carries one — a data object (gethydro/getparticles/getgravity/getclumps/getrt), a projection map, or a velocity_cube/los_cube. Deterministic: it reads only the snapshot's own metadata, so it is safe to compare across runs.

gas = gethydro(getinfo(100, "/data/sim"))
provenance(gas)                      # data object
provenance(projection(gas, :sd))     # projection map
provenance(velocity_cube(gas))       # LOS / velocity cube
provenance(gas.info)                 # the InfoType directly

For a NamedTuple-style result that carries no .info (a pdf, a timeseries table, a position_velocity diagram), take the provenance of the source data object you computed it from.

Mera.provenance_stringMethod
provenance_string(x) -> String

A compact one-line provenance string — drop it into a figure caption, a COMMENT card when you savefits, or a log. Accepts the same inputs as provenance (or a Provenance). The time is shown as z=… for a cosmological run, otherwise in Myr/Gyr.

Mera.quicklookMethod
quicklook(output; path=".", budget=2_000_000, read=true, res=256, lmax=nothing,
          particle_subsample=1.0, datatypes=[:hydro,:stars,:dm], directions=[:z,:x,:y],
          verbose=true) -> QuickLookResult

A first impression of a simulation output in seconds. Reads the header for instant facts (box, levels, finest cell, time/redshift, and the cell & particle census) and — unless read=false — does a single budgeted hydro read (only the coarse AMR levels when the full output would exceed budget cells), then builds surface-density projections along each axis (.maps.x/.y/.z — face-on plus the two edge-on views), a ρ–T phase diagram, a global snapshot budget (gas / stellar / dark-matter mass and the current SFR), and prints a compact dashboard. On an MHD run it additionally reads the magnetic field and adds a face-on |B| map (.maps.bmag, μG) plus |B| and plasma-β ranges.

  • budget — cell-count cap; if the full output is predicted larger, only coarse levels are read and the result is flagged sampled=true (estimates labelled APPROXIMATE). lmax overrides the choice.
  • read=false — header-only (sub-second): box, levels, finest cell, ncpu, fields, time/redshift.
  • res — pixel size of the quick map.
  • datatypes — which components to show, any subset of [:hydro, :stars, :dm] (default all that are present). [:hydro] reads gas only; [:stars] or [:dm] skip the gas read entirely (faster); the panels and census adapt to what was read.
  • directions — which gas projection axes, any subset of [:z, :x, :y] (:z = face-on for a disk in the xy-plane; :x, :y = the two edge-on views). Use directions=[:z] for a single, compact map.
  • particle_subsample — for very large particle runs, read only ~this fraction of the particle CPU files (e.g. 0.1); RAMSES balances ~equal particles per CPU, so this reads ~that fraction of particles (skipping whole files → cuts I/O & memory). The particle census, masses and SFR are then scaled up by 1/fraction and flagged approximate. (Gas is bounded separately by budget/lmax.)

When a particle file is present, the budget includes the stellar and dark-matter mass and the current star-formation rate (10/100 Myr windows + lifetime mean, see sfr_snapshot); these are exact even when the hydro read is coarse. Returns a QuickLookResult; figure/summary data is in .maps, .phase, .budget.

For radial density profiles and any other composable cards, use report — the composable form of this first look: report(output) runs a default card trio (map, phase, radial profile), and you can add/replace cards (projections, phases, profiles, SFR, scalars, …) and render to ascii / plot / JLD2 / file.

Mera.quicklookplotMethod
quicklookplot(q::QuickLookResult; kwargs...) -> Makie.Figure

Render a QuickLookResult as a multi-panel dashboard that adapts to what was read: gas surface density along each requested axis (:z face-on, :x/:y edge-on), face-on stellar and dark-matter surface density when particles are present, the ρ–T phase diagram, and a text census (cells, particles, masses, SFR, ranges). Panels fill a tight 3-column grid; colormaps are the colorblind-safe viridis/inferno. Needs a Makie backend loaded (using CairoMakie or GLMakie); the figure is returned, so save it with Makie.save("ql.png", fig).

using CairoMakie
q = quicklook(300; path="…")
fig = quicklookplot(q)
Mera.recommend_buffer_sizeMethod
recommend_buffer_size(characteristics::Dict)

Recommend optimal buffer size based on simulation characteristics.

Mera.redshiftMethod
redshift(info::InfoType) -> Float64

Cosmological redshift of the snapshot, z = 1/aexp - 1. Returns 0.0 for a non-cosmological run (where aexp = 1).

Mera.renderMethod
render(report::QuickReport, backend::Symbol; kwargs...)

Render a [QuickReport] to a backend: :ascii (text dashboard, default), :jld2 (full round-trip via loadreport), :file (a .jld2 + _summary.txt bundle), or :plot (requires a Makie package extension — using CairoMakie).

Mera.reportMethod
report(plan::ReportPlan; output=:ascii, budget_s=nothing, verbose=true)
report(sim_output::Int; path=".", cards=:default, output=:ascii, lmax=-1, budget=2_000_000, budget_s=nothing, verbose=true)

Run a composable first-look [ReportPlan] and return a [QuickReport]. Each datatype is read once with the minimal variable set unioned across its cards (via getvar_requirements). output (the backend) is rendered immediately — :ascii prints a dashboard, :jld2/:file write the report — and the QuickReport is returned for re-rendering / re-analysis.

report(1; path=sim, output=:ascii, cards=[
    ProjectionCard(:hydro, :sd; unit=:Msol_pc2, res=512),
    PhaseCard(:hydro, :rho, :T; weight=:mass, xunit=:nH, yunit=:K),
    ScalarCard(:hydro, :mass; reduce=:sum, unit=:Msol),
])
Mera.required_raw_varsMethod
required_raw_vars(kind::Symbol, var::Symbol) -> Set{Symbol}

The transitive set of leaf (raw) symbols a derived var is built from, for the given data-type kind (:hydro, :gravity, :rt, :particle, :clump). Includes geometry leaves; use getvar_requirements for the physical-variables-to-read set.

Mera.reset_auto_optimization!Method
reset_auto_optimization!()

Reset the automatic optimization state, forcing re-optimization on next data load.

Mera.reset_mera_ioMethod
reset_mera_io()

Reset Mera I/O settings to default values.

This clears any custom buffer sizes, disables optimizations, and clears the cache. Useful if you want to start fresh or if you're experiencing issues.

Example

julia> reset_mera_io()
🔄 MERA I/O RESET
=================
✅ Buffer size reset to 64KB (default)
✅ File caching enabled (default)
✅ Cache cleared (0 entries removed)
✅ Settings reset to defaults
Mera.resolve_losMethod
resolve_los(; los, theta, phi, inclination, azimuth, axis,
              direction=:z, angle_unit=:deg, up=nothing, L=nothing) -> (los_vec, up_hint)

Resolve a user-facing view specification into a (los_vec, up_hint) pair. Give exactly one of the alternatives below (a second one raises an error — no silent precedence). All angles are in angle_unit (:deg by default, or :rad):

  1. explicit los 3-vector,
  2. inclination/azimuth — tilt the view away from a reference axis by inclination (0 ⇒ looking straight down the axis, 90° ⇒ perpendicular to it) and rotate around the axis by azimuth. axis defaults to the box :z; use :x/:y/:z, a 3-vector, or :angmom (the object's angular momentum L, for disks). The reference axis is kept pointing "up".
  3. spherical angles (theta, phi) about the box axes (los=[sinθcosφ, sinθsinφ, cosθ]),
  4. preset direction: :x/:y/:z, :faceon (look along L), :edgeon (⟂ L, up = ).

:faceon/:edgeon and axis=:angmom need the pre-computed L; the projection wiring supplies it via getvar(obj,[:lx,:ly,:lz]). The image roll (position_angle) is applied separately in build_camera_basis, so it is not a line-of-sight specifier here. Pure — touches no data.

Mera.rotation_sequenceFunction
rotation_sequence(dataobject, var, [unit]; sweep=:azimuth, angles,
                  axis=:angmom, inclination=0, fov=nothing, fov_unit=:standard,
                  center=[:bc], range_unit=:standard, res=256, <projection kwargs>)
    -> Vector{AMRMapsType}

Render var from a sequence of viewing angles for an orbit movie, all sharing ONE fixed field of view so successive frames do not jitter (a plain per-frame projection recomputes the extent for every angle). sweep selects which angle varies (:azimuth, :inclination, or :position_angle) and angles is the list of values (degrees by default).

The shared FOV is the symmetric window ±fov (in fov_unit) about center. If fov is nothing it is set to the maximum cell/particle distance from center (so the object fits at every angle). Returns a Vector of map objects — one per angle — ready to animate.

Mera.rotationcurveMethod
rotationcurve(dataobject; center=[:bc], center_unit=:standard, rvar=:r_sphere, nbins=50,
              xrange=nothing, scale=:linear, xunit=:kpc, mask=[false]) -> NamedTuple

Circular-velocity (rotation) curve from the enclosed mass. Bin all cells/particles by radius rvar (:r_sphere or :r_cylinder) about a physical center, form the enclosed mass M(<r) = Σ mass(< r), and return the Newtonian circular velocity v_circ = √(G·M(<r)/r) and the gravitational acceleration g = G·M(<r)/r². Needs a :mass field (hydro / particles); mass-bearing components can be combined by concatenating their radius/mass (see the component-split example in the profiles tutorial).

Returns x (the outer bin-edge radius in xunit, where the enclosed mass is complete), edges, count, m_enc (enclosed mass, M⊙), v_circ (km/s) and g (cm/s²). The cumulative mass Σ mass(< r) is the mass interior to each bin's upper edge, so the velocity/acceleration are evaluated at that same radius (edges[2:end]) — pairing them with the bin centre would mix a half-bin of mass against a smaller radius and overestimate the inner curve.

Mera.run_benchmarkMethod
run_benchmark(folder; runs=1) → IOBenchmark

Executes IOPS, throughput, and open/close tests. Returns all samples, stats, timings, and thread configurations as an IOBenchmark.

Mera.safe_executeMethod

Enhanced exception handler with automatic notification

Wraps risky code with automatic exception notification including full context.

Parameters:

  • code_block: Function to execute with exception handling
  • task_description: Description of what the code is doing
  • zulip_channel: Channel for error notifications (default: "errors")
  • zulip_topic: Topic for error notifications (default: "Exception Reports")
  • include_context: Include system context in error report (default: true)

Examples:

# Basic exception handling with notification
result = safe_execute("Galaxy temperature calculation") do
    calculate_galaxy_temperatures(data)
end

# Custom error channel and additional context
result = safe_execute("Critical simulation step", 
                     zulip_channel="critical-errors",
                     include_context=true) do
    run_critical_simulation_step()
end
Mera.safe_printlnMethod
safe_println(args...)

Thread-safe wrapper for println() that uses a global lock to prevent interleaved output from multiple threads. Essential for readable output in multithreaded environments.

Mera.save_benchmark_resultsMethod
save_benchmark_results(results::Dict, filename::String)

Export benchmark results to CSV, JSON, and human-readable summary formats.

Mera.save_clumpsMethod
save_clumps(filename, cat::ClumpCatalog) -> String

Write a ClumpCatalog to filename as a JLD2 file (full fidelity — per-clump fields, boundedness, nested subclumps, the hierarchy tree, and meta are all preserved). A .jld2 extension is appended if missing. Reload with load_clumps. For a flat tabular export (CSV/DataFrame) use clumptable instead.

save_clumps("clumps_out100", cat)
cat2 = load_clumps("clumps_out100.jld2")
Mera.savecubeMethod
savecube(c::LosCubeType, filename; verbose=true) -> String
loadcube(filename; verbose=true) -> LosCubeType

Save / load a LOS cube to a JLD2 file (the .jld2 extension is added if missing). The cube, its axes, the binned quantity/units, the camera basis and the simulation info are all stored.

Mera.savedataMethod

Save loaded simulation data into a compressed/uncompressed JLD2 format:

  • write new file; add datatype to existing file
  • running number is taken from original RAMSES folders
  • use different compression methods
  • add a string to describe the simulation
  • toggle verbose mode
function savedata( dataobject::DataSetType;
                    path::String="./",
                    fname = "output_",
                    fmode::Any=nothing,
                    dataformat::Symbol=:JLD2,
                    compress::Any=nothing,
                    comments::Any=nothing,
                    merafile_version::Float64=1.,
                    verbose::Bool=true)
return 

Arguments

Required:

  • dataobject: needs to be of type: "HydroDataType", "PartDataType", "GravDataType", "ClumpDataType", "RtDataType"
  • fmode: nothing is written/appended by default to avoid overwriting files by accident. Need: fmode=:write (new file, or overwrite an existing file); fmode=:append adds a further datatype to an existing file. Re-appending a datatype that is already stored in the file is not supported and raises an error (existing datatypes are not overwritten in place).

Predefined/Optional Keywords:

  • path: path to save the file; default is local path.
  • fname: default name of the files "output_" and the running number is added. Change the string to apply a user-defined name.
  • dataformat: currently, only JLD2 can be selected.
  • compress: by default LZ4 compression is activated. compress=false deactivates it.

This build (JLD2 0.6) compresses with LZ4 (best ratio); a legacy LZ4FrameCompressor() is accepted, and ZlibCompressor()/Bzip2Compressor() fall back to LZ4 with a warning.

  • comments: add a string that includes e.g. a description about your simulation
  • merafile_version: default: 1.; current only version
  • verbose: print timestamp and further information on screen; default: true

Defined Methods - function defined for different arguments

  • savedata( dataobject::DataSetType; ...) # note: fmode needs to be given for action!
  • savedata( dataobject::DataSetType, fmode::Symbol; ...)
  • savedata( dataobject::DataSetType, path::String; ...)
  • savedata( dataobject::DataSetType, path::String, fmode::Symbol; ...)
Mera.savefitsFunction
savefits(map::DataMapsType, var::Symbol, filename; unit=nothing, verbose=true) -> String
savefits(cube::LosCubeType, filename; verbose=true) -> String

Write an off-axis map (a variable of an AMRMapsType/PartMapsType) or a whole LosCubeType to a FITS file with a minimal WCS (linear pixel scale; reference pixel at the projection centre; the cube's 3rd axis is the binned quantity), for interoperability with DS9 / CASA / astropy.

This is a package extension: it is only available after using FITSIO (add FITSIO to your environment). Without it, a helpful error is thrown. JLD2 storage (savecube/loadcube) needs no extra package.

Mera.savemapMethod
savemap(p::DataMapsType, filename; verbose=true) -> String
loadmap(filename; verbose=true) -> DataMapsType

Save / load a projection result (an AMRMapsType/PartMapsType from projection) to a JLD2 file — the same lightweight, Julia-native way savecube/loadcube persist a LOS cube (the .jld2 extension is added if missing). The whole object round-trips: every map and its unit, the extent/pixsize, the off-axis camera basis, and the simulation info — so a reloaded map still plots, re-projects, and carries provenance.

p = projection(gas, [:sd, :vx])
savemap(p, "maps.jld2")
p2 = loadmap("maps.jld2")        # AMRMapsType, identical to p

JLD2 is a subset of the HDF5 format, so these files also open in h5py and other HDF5 readers.

Mera.savemovieFunction
savemovie(m::MeraMovie, file="movie.gif"; colormap=:fire, log=true, colorrange=:global,
          clip=(0.0, 1.0), fps=10, tags=nothing, annotate=true, save_frames=nothing,
          verbose=true) -> file

Write a MeraMovie to an animated GIF (file), using the bundled FileIO/Images (no extra package needed). Each frame is normalised over a colour range and mapped through a colormap.

  • colormap:fire (default) or :gray, or a function t∈[0,1] -> (r,g,b).
  • log — map log10 of the (positive) values (default; good for density).
  • colorrange:global (one range across all frames — steady brightness), :perframe, or an explicit (lo, hi) (already in log space when log=true).
  • clip — drop this lower/upper quantile fraction when auto-computing the range.
  • fps — playback frame rate of the GIF.

Tags (per-frame labels). Pass tags to label each frame:

  • :time"t=<time> <unit>", :output"output 00001";
  • a vector of strings (one per frame); or a function k -> String;
  • a tuple of any of the above stacks multiple lines, e.g. tags=(:output, :time).

The labels are printed (when verbose) and, when annotate=true, burned onto the frames with a built-in bitmap font (no font dependency). Control the look:

  • tag_scale — font size: :auto (default, scales with the frame) or an integer.
  • tag_position:topleft (default), :topright, :bottomleft, :bottomright, or an explicit (row, col) pixel.
  • tag_color:white (default), :yellow, :red, :cyan, :green, :black, an RGB, or an (r,g,b) tuple.

Scratch frames. Set save_frames to a directory to also write each rendered frame as frame_00001.png, … in it (the directory is created). Those PNGs can be re-assembled later with moviefromframes — or fed to ffmpeg for an MP4.

Persisting the movie object. A file ending in .jld2 stores the whole MeraMovie (the numeric frames + metadata) to a JLD2 file instead of encoding a GIF — reload it with loadmovie. Same Julia-native way savemap/savecube persist a map or a cube; nothing is re-rendered, so it round-trips exactly.

savemovie(m, "density.gif"; tags=:time, fps=12)
savemovie(m, "density.gif"; tags=(:output, :time), tag_position=:bottomright, tag_color=:yellow)
savemovie(m, "density.gif"; tags=:output, tag_scale=3, save_frames="frames/")
savemovie(m, "density.jld2")        # persist the MeraMovie object (→ loadmovie)
Mera.send_resultsMethod

Send multiple plots or results with a single notification

Convenience function for common research workflows where you want to share multiple files (plots, data, results) at once.

Parameters:

  • msg: Message to send
  • folder: Path to folder containing files to attach
  • file_pattern: Pattern to match files (default: images only)
  • max_files: Maximum number of files to attach (default: 10)
  • zulip_channel: Zulip channel/stream name (default: "results")
  • zulip_topic: Zulip topic name (default: "Analysis Results")

Examples:

# Send all plots from analysis folder
send_results("Temperature analysis complete!", "./plots/")

# Send specific files
send_results("Key results ready!", ["figure1.png", "data.csv", "summary.txt"])

# Send with custom channel and topic
send_results("Paper plots ready!", "./figures/", 
             zulip_channel="publications", zulip_topic="Paper 1 - Figures")
Mera.sfrMethod
sfr(p::PartDataType; tbinsize=10.0, trange=[0.0, missing], mass=:auto, mask=[false],
    mode=:none, closed=:left) -> (t_Myr, sfr)

Star-formation history from the star particles: t_Myr are the left bin edges [Myr] and sfr is the star-formation rate per bin M⊙/yr.

Star particles are selected by the universal RAMSES sentinel birth ≠ 0 (non-star particles have birth == 0); the sign/scale of the stored birth time varies between runs, so a birth > 0 test is not reliable. The formation-time axis is physical and RAMSES-version aware:

  • non-cosmological runs — the proper birth time getvar(:birth, :Myr) (formation time in the run's own time coordinate; it may be negative — the origin is arbitrary and does not affect the SFH shape).

  • cosmological runs — :birth is a super-conformal time (≤ 0 at a = 1), not a physical time, so sfr bins the physical getvar(:formation_time, :Myr) (cosmic time of formation, from the Friedmann table) instead.

  • tbinsize — bin width in Myr.

  • trange[t0, t1] in Myr; each entry defaults to missing ⇒ the earliest / latest stellar formation time, so the bins span exactly the star-formation history.

  • mass — mass field to integrate; :auto (default) prefers a stored initial-mass column (:minit, :mass_init, …) and falls back to current :mass. SFR should use the initial stellar mass; current mass underestimates it by post-formation mass loss.

  • mask — a Bool vector over the particles (length == number of particles) to subselect.

  • mode:none (M⊙/yr) or :probability (normalised SFH fraction).

  • eta_sn, t_sn_delaySN mass-loss correction for runs that store only the current mass: a star older than t_sn_delay Myr (SN onset, default 5) has shed a fraction eta_sn of its birth mass, so its mass is rescaled by 1/(1-eta_sn) to recover the initial mass. Default eta_sn=0 is a no-op; ignored (with a warning) when an initial-mass field is used — it is already the birth mass.

t, s = sfr(parts; tbinsize=50.0)            # SFR [M⊙/yr] vs t [Myr]
t, s = sfr(parts; mass=:minit)              # force a specific initial-mass field
t, s = sfr(parts; eta_sn=0.2)               # reconstruct birth mass from current mass (20% SN loss)

See also sfr_snapshot for the current SFR from a single snapshot.

Mera.sfr_snapshotMethod
sfr_snapshot(p::PartDataType; windows=[5.0, 10.0, 100.0], time_unit=:Myr, mass=:auto,
             mask=[false]) -> NamedTuple

Star-formation rate from a single snapshot, from the star particles (birth ≠ 0; cosmological birth times are converted to ages via stellar_age). Two complementary measures:

  • Instantaneous (recent window). For each look-back window Δt in windows, SFR(Δt) = M_*(age ≤ Δt) / Δt — the standard observational "current SFR" (Hα ≈ 5–10 Myr, FUV ≈ 100 Myr). Returned in M⊙/yr.
  • Lifetime mean. total stellar mass / age of the oldest star, in M⊙/yr.

mass selects the mass field; :auto (default) prefers a stored initial-mass column and falls back to current :mass — SFR should use the initial stellar mass (current mass is reduced by post-formation mass loss). Returns (; windows, time_unit, sfr, sfr_mean, n_stars, stellar_mass_Msol, oldest_age, mass_field) where sfr is the per-window vector aligned to windows. With no star particles every rate is 0.0.

s = sfr_snapshot(parts)            # default 5/10/100 Myr windows + mean (auto initial-mass)
s.sfr                              # [SFR(5 Myr), SFR(10 Myr), SFR(100 Myr)]  M⊙/yr
s.sfr_mean                         # lifetime-averaged SFR  M⊙/yr
s.mass_field                       # which mass field was used (e.g. :minit or :mass)

See also sfr for the full star-formation history SFR(t).

Mera.shellregionFunction

Cutout sub-regions of the data base of DataSetType

  • select shape of a shell-region
  • select size of a region (with or w/o intersecting cells)
  • give the spatial center (with units) of the data relative to the full box
  • relate the coordinates to a direction (x,y,z)
  • inverse the selected region
  • pass a struct with arguments (myargs)
shellregion(dataobject::DataSetType, shape::Symbol=:cylinder;
            radius::Array{<:Real,1}=[0.,0.],  # cylinder, sphere;
            height::Real=0.,                  # cylinder
            direction::Symbol=:z,             # cylinder

            center::Array{<:Any,1}=[0., 0., 0.],   # all
            range_unit::Symbol=:standard,  # all
            cell::Bool=true,                        # hydro and gravity
            inverse::Bool=false,                    # all
            verbose::Bool=true,             # all
            myargs::ArgumentsType=ArgumentsType() ) # all

Arguments

Required:

  • dataobject: needs to be of type: "DataSetType"
  • shape: select between region shapes: :cylinder/:disc, :sphere

Predefined/Optional Keywords:

For cylindrical shell-region, related to a given center:

  • radius: the inner and outer radius of the shell in units given by argument range_unit and relative to the given center
  • height: the hight above and below a plane [-height, height] in units given by argument range_unit and relative to the given center
  • direction: todo

For spherical shell-region, related to a given center:

  • radius: the inner and outer radius of the shell in units given by argument range_unit and relative to the given center

Keywords related to all region shapes

  • range_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 argument range_unit; by default [0., 0., 0.]; the box-center can be selected by e.g. [:bc], [:boxcenter], [value, :bc, :bc], etc..
  • inverse: inverse the region selection = get the data outside of the region
  • cell: take intersecting cells of the region boarder into account (true) or only the cells-centers within the selected region (false)
  • verbose: print timestamp, selected vars and ranges on screen; default: true
  • myargs: pass a struct of ArgumentsType to pass several arguments at once and to overwrite default values of radius, height, direction, center, range_unit, verbose
Mera.show_mera_configMethod
show_mera_config()

Display current Mera I/O configuration settings.

Shows buffer size, caching status, and performance-related settings in a user-friendly format.

Example

julia> show_mera_config()
🔧 MERA I/O CONFIGURATION
========================
Buffer size:     128KB (131072 bytes)
File caching:    Enabled ✅
Large buffers:   Enabled ✅
Cache entries:   3 files cached
Status:          Optimized for large simulations
Mera.show_threading_infoMethod
show_threading_info()

Display information about Julia threading configuration and recommendations.

Mera.showprogressMethod
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 defaults
Mera.sliceFunction
slice(obj, var, [unit]; slice_axis=:z, slice_pos=0.5, slice_unit=:standard, lmax=obj.lmax,
      center=[0.,0.,0.], xrange=…, yrange=…, zrange=…, range_unit=:standard,
      max_bytes=4e9, pos_unit=:standard, verbose=true) -> CoveringGridResult

A 2-D fixed-resolution buffer: a single-cell-thick, non-integrated cut through the AMR data at slice_pos along slice_axis (:x/:y/:z), resampled to level lmax (cf. covering_grid for the 3-D version, projection for the integrated map). slice_pos is in slice_unit (:standard ⇒ a fraction of the box). The result's grid[var] is a 2-D array.

sl = slice(gas, :rho, :nH; slice_axis=:z, slice_pos=0.5)   # mid-plane n_H map
sl[:rho]                                                    # 2-D array
Mera.smart_io_setupMethod
smart_io_setup(simulation_path::String, output_num::Int; benchmark=false, verbose=true)

Intelligent I/O setup that combines analysis and optional benchmarking.

Mera.smooth_transitionMethod
smooth_transition(distance_to_boundary, boundary_width)

Calculate smooth transition weight for boundary cells.

Creates a smooth transition zone that eliminates sharp cutoffs while maintaining the overall cylindrical geometry. Uses a cosine-based transition function.

Arguments

  • distance_to_boundary: Signed distance from cylinder boundary (negative = inside)
  • boundary_width: Width of transition zone

Returns

  • Float64: Weight between 0.0 (excluded) and 1.0 (fully included)
Mera.stellar_ageMethod
stellar_age(info::InfoType, birth; unit::Symbol=:Gyr)

Physical age of star particle(s) for a cosmological RAMSES run, from their super-conformal :birth time(s) (scalar or array, as returned by getvar(particles, :birth)). The age is t_proper(a_snap) − t_proper(a_birth) obtained from the Friedmann table (see cosmology); info.time provides the snapshot's conformal time.

unit is a time unit symbol like elsewhere in Mera: :Gyr (default), :Myr, :yr, :s (:standard ⇒ seconds). Non-star sentinels (birth = 0) and any birth time ≥ the snapshot return age 0. This is the conversion used internally by getvar(particles, :age) on cosmological runs.

part = getparticles(info)                 # cosmological run
ages = stellar_age(info, getvar(part, :birth))          # [Gyr]
ages = stellar_age(info, getvar(part, :birth), unit=:Myr)
Mera.storageoverviewMethod
storageoverview(dataobject::InfoType; verbose::Bool=true)

Provide a storage overview for loaded data, showing memory usage and data structure information.

Arguments

  • dataobject::InfoType: Simulation info object
  • verbose: Control level of output detail

Description

Displays comprehensive information about the storage characteristics of the selected simulation output. It helps users understand the resource requirements and structure of their data.

Examples

# Get storage overview for hydro data
storageoverview(info, true)

# Brief storage information
storageoverview(info, false)
Mera.subregionFunction

Cutout sub-regions of the data base of DataSetType

  • select shape of a region
  • select size of a region (with or w/o intersecting cells)
  • give the spatial center (with units) of the data relative to the full box
  • relate the coordinates to a direction (x,y,z)
  • inverse the selected region
  • pass a struct with arguments (myargs)
subregion(dataobject::DataSetType, shape::Symbol=:cuboid;
            xrange::Array{<:Any,1}=[missing, missing],  # cuboid
            yrange::Array{<:Any,1}=[missing, missing],  # cuboid
            zrange::Array{<:Any,1}=[missing, missing],  # cuboid

            radius::Real=0.,              # cylinder, sphere
            height::Real=0.,              # cylinder
            direction::Symbol=:z,         # cylinder

            center::Array{<:Any,1}=[0.,0.,0.],     # all
            range_unit::Symbol=:standard,           # all
            cell::Bool=true,                        # hydro and gravity
            inverse::Bool=false,                    # all
            verbose::Bool=true,             # all
            myargs::ArgumentsType=ArgumentsType() ) # all

Arguments

Required:

  • dataobject: needs to be of type: "DataSetType"
  • shape: select between region shapes: :cuboid, :cylinder/:disc, :sphere

Predefined/Optional Keywords:

For cuboid region, related to a given center:

  • xrange: the range between [xmin, xmax] in units given by argument range_unit and relative to the given center; zero length for xmin=xmax=0. is converted to maximum possible length
  • yrange: the range between [ymin, ymax] in units given by argument range_unit and relative to the given center; zero length for ymin=ymax=0. is converted to maximum possible length
  • zrange: the range between [zmin, zmax] in units given by argument range_unit and relative to the given center; zero length for zmin=zmax=0. is converted to maximum possible length

For cylindrical region, related to a given center:

  • radius: the radius between [0., radius] in units given by argument range_unit and relative to the given center
  • height: the hight above and below a plane [-height, height] in units given by argument range_unit and relative to the given center
  • direction: todo

For spherical region, related to a given center:

  • radius: the radius between [0., radius] in units given by argument range_unit and relative to the given center

Keywords related to all region shapes

  • range_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 argument range_unit; by default [0., 0., 0.]; the box-center can be selected by e.g. [:bc], [:boxcenter], [value, :bc, :bc], etc..
  • inverse: inverse the region selection = get the data outside of the region
  • cell: take intersecting cells of the region boarder into account (true) or only the cells-centers within the selected region (false)
  • verbose: print timestamp, selected vars and ranges on screen; default: true
  • myargs: pass a struct of ArgumentsType to pass several arguments at once and to overwrite default values of xrange, yrange, zrange, radius, height, direction, center, range_unit, verbose
Mera.subregionMethod
subregion(obj, region::AbstractRegion; split=true, inverse=false, nsub=8, verbose=true)

Select the data covered by a composable region (Sphere, Cuboid, Cylinder, SphericalShell, or any boolean combination //\/!). Works on hydro, gravity, RT (AMR cells) and particle data.

For AMR cell data with split=true (default) each kept cell carries an exact :fraction ∈ (0,1] — the volume fraction inside the region — and getvar(:mass) / getvar(:volume) / msum report the exact in-region totals (no boundary over/under- counting). With split=false whole cells are kept by a centre-inside test (the classic behaviour) and no :fraction is attached. nsub (default 8) is the per-axis sub-sampling of boundary cells for curved/composite regions (diminishing returns past ~8).

For particle data the region is a point-membership test (particles are points — there is no fractional volume, so split/nsub do not apply). inverse=true selects the complement.

Mera.subregioncuboidMethod
subregioncuboid(dataobject::GravDataType; kwargs...)

Select a cuboid (rectangular box) subregion from gravity data using AMR-aware filtering.

This function extracts all gravity cells that lie within or intersect a specified rectangular region. It supports both cell-based and point-based selection modes for precise control over boundary handling in adaptive mesh refinement (AMR) simulations.

Arguments

  • dataobject::GravDataType: Input gravity data object from getgravity()

Keywords

  • xrange::Array{<:Any,1}=[missing, missing]: X-coordinate range [min, max]
  • yrange::Array{<:Any,1}=[missing, missing]: Y-coordinate range [min, max]
  • zrange::Array{<:Any,1}=[missing, missing]: Z-coordinate range [min, max]
  • center::Array{<:Any,1}=[0., 0., 0.]: Reference center for ranges
  • range_unit::Symbol=:standard: Units for ranges (:standard, :kpc, :Mpc, etc.)
  • cell::Bool=true: Cell-based (true) vs point-based (false) selection mode
  • inverse::Bool=false: Select outside the region instead of inside
  • verbose::Bool=verbose_mode: Print progress information

Selection Modes

  • Cell-based (cell=true): Includes cells that intersect the region boundary
  • Point-based (cell=false): Includes only cells whose centers lie within the region

Returns

  • GravDataType: New gravity data object containing filtered cells

Examples

# Select central 20x20x4 kpc box
subregion = subregioncuboid(gravity, 
    xrange=[-10., 10.], yrange=[-10., 10.], zrange=[-2., 2.],
    center=[:boxcenter], range_unit=:kpc)

# Inverse selection (everything outside the box)
subregion = subregioncuboid(gravity,
    xrange=[0.3, 0.7], yrange=[0.3, 0.7], zrange=[0.4, 0.6],
    inverse=true)

See Also

  • subregioncylinder: Cylindrical subregions
  • subregionsphere: Spherical subregions
  • subregion: Unified interface for all geometries
Mera.subregioncuboidMethod
subregioncuboid(dataobject::HydroDataType; kwargs...)

Select a cuboid (rectangular box) subregion from hydro data using AMR-aware filtering.

This function extracts all hydro cells that lie within or intersect a specified rectangular region. It supports both cell-based and point-based selection modes for precise control over boundary handling in adaptive mesh refinement (AMR) simulations.

Arguments

  • dataobject::HydroDataType: Input hydro data object from gethydro()

Keywords

  • xrange::Array{<:Any,1}=[missing, missing]: X-coordinate range [min, max]
  • yrange::Array{<:Any,1}=[missing, missing]: Y-coordinate range [min, max]
  • zrange::Array{<:Any,1}=[missing, missing]: Z-coordinate range [min, max]
  • center::Array{<:Any,1}=[0., 0., 0.]: Reference center for ranges
  • range_unit::Symbol=:standard: Units for ranges (:standard, :kpc, :Mpc, etc.)
  • cell::Bool=true: Cell-based (true) vs point-based (false) selection mode
  • inverse::Bool=false: Select outside the region instead of inside
  • verbose::Bool=verbose_mode: Print progress information

Selection Modes

  • Cell-based (cell=true): Includes cells that intersect the region boundary
  • Point-based (cell=false): Includes only cells whose centers lie within the region

Returns

  • HydroDataType: New hydro data object containing filtered cells

Examples

# Select central 20x20x4 kpc box
subregion = subregioncuboid(gas, 
    xrange=[-10., 10.], yrange=[-10., 10.], zrange=[-2., 2.],
    center=[:boxcenter], range_unit=:kpc)

# Inverse selection (everything outside the box)
subregion = subregioncuboid(gas,
    xrange=[0.3, 0.7], yrange=[0.3, 0.7], zrange=[0.4, 0.6],
    inverse=true)

See Also

  • subregioncylinder: Cylindrical subregions
  • subregionsphere: Spherical subregions
  • subregion: Unified interface for all geometries
Mera.subregioncuboidMethod
subregioncuboid(dataobject::RtDataType; kwargs...)

Select a cuboid (rectangular box) subregion from RT data using AMR-aware filtering.

This function extracts all RT cells that lie within or intersect a specified rectangular region. It supports both cell-based and point-based selection modes for precise control over boundary handling in adaptive mesh refinement (AMR) simulations.

Arguments

  • dataobject::RtDataType: Input RT data object from getrt()

Keywords

  • xrange::Array{<:Any,1}=[missing, missing]: X-coordinate range [min, max]
  • yrange::Array{<:Any,1}=[missing, missing]: Y-coordinate range [min, max]
  • zrange::Array{<:Any,1}=[missing, missing]: Z-coordinate range [min, max]
  • center::Array{<:Any,1}=[0., 0., 0.]: Reference center for ranges
  • range_unit::Symbol=:standard: Units for ranges (:standard, :kpc, :Mpc, etc.)
  • cell::Bool=true: Cell-based (true) vs point-based (false) selection mode
  • inverse::Bool=false: Select outside the region instead of inside
  • verbose::Bool=verbose_mode: Print progress information

Selection Modes

  • Cell-based (cell=true): Includes cells that intersect the region boundary
  • Point-based (cell=false): Includes only cells whose centers lie within the region

Returns

  • RtDataType: New RT data object containing filtered cells

Examples

# Select central 20x20x4 kpc box
subregion = subregioncuboid(rt, 
    xrange=[-10., 10.], yrange=[-10., 10.], zrange=[-2., 2.],
    center=[:boxcenter], range_unit=:kpc)

# Inverse selection (everything outside the box)
subregion = subregioncuboid(rt,
    xrange=[0.3, 0.7], yrange=[0.3, 0.7], zrange=[0.4, 0.6],
    inverse=true)

See Also

  • subregioncylinder: Cylindrical subregions
  • subregionsphere: Spherical subregions
  • subregion: Unified interface for all geometries
Mera.subregioncylinderMethod
subregioncylinder(dataobject::GravDataType; kwargs...)

Select a cylindrical subregion from gravity data using AMR-aware filtering.

This function extracts all gravity cells that lie within or intersect a specified cylindrical region. The cylinder is defined by a radius, height, center position, and orientation axis. It supports both cell-based and point-based selection modes for precise boundary handling.

Arguments

  • dataobject::GravDataType: Input gravity data object from getgravity()

Keywords

  • radius::Real=0.: Cylinder radius in units specified by range_unit
  • height::Real=0.: Total cylinder height (extends ±height/2 from center plane)
  • center::Array{<:Any,1}=[0., 0., 0.]: Cylinder center position
  • range_unit::Symbol=:standard: Units (:standard, :kpc, :Mpc, etc.)
  • direction::Symbol=:z: Cylinder axis orientation (:x, :y, or :z)
  • cell::Bool=true: Cell-based (true) vs point-based (false) selection mode
  • inverse::Bool=false: Select outside the region instead of inside
  • verbose::Bool=verbose_mode: Print progress information

Selection Modes

  • Cell-based (cell=true): Includes cells that intersect the cylinder boundary
  • Point-based (cell=false): Includes only cells whose centers lie within the cylinder

Returns

  • GravDataType: New gravity data object containing filtered cells

Examples

# Select 5 kpc radius, 4 kpc height cylinder along z-axis
subregion = subregioncylinder(gravity,
    radius=5., height=4., center=[:boxcenter],
    range_unit=:kpc, direction=:z)

# Disk selection (very thin cylinder)
disk = subregioncylinder(gravity,
    radius=10., height=0.5, center=[24., 24., 24.],
    range_unit=:kpc, direction=:z)

See Also

  • subregioncuboid: Rectangular subregions
  • subregionsphere: Spherical subregions
  • subregion: Unified interface for all geometries
Mera.subregioncylinderMethod
subregioncylinder(dataobject::HydroDataType; kwargs...)

Select a cylindrical subregion from hydro data using AMR-aware filtering.

This function extracts all hydro cells that lie within or intersect a specified cylindrical region. The cylinder is defined by a radius, height, center position, and orientation axis. It supports both cell-based and point-based selection modes for precise boundary handling.

Arguments

  • dataobject::HydroDataType: Input hydro data object from gethydro()

Keywords

  • radius::Real=0.: Cylinder radius in units specified by range_unit
  • height::Real=0.: Total cylinder height (extends ±height/2 from center plane)
  • center::Array{<:Any,1}=[0., 0., 0.]: Cylinder center position
  • range_unit::Symbol=:standard: Units (:standard, :kpc, :Mpc, etc.)
  • direction::Symbol=:z: Cylinder axis orientation (:x, :y, or :z)
  • cell::Bool=true: Cell-based (true) vs point-based (false) selection mode
  • inverse::Bool=false: Select outside the region instead of inside
  • smooth_boundary::Bool=false: Enable smooth boundary transitions (eliminates grid artifacts)
  • boundary_width::Real=0.1: Relative width of smooth transition zone (0.0-1.0)
  • verbose::Bool=verbose_mode: Print progress information

Selection Modes

  • Cell-based (cell=true): Includes cells that intersect the cylinder boundary
  • Point-based (cell=false): Includes only cells whose centers lie within the cylinder

Smooth Boundaries (OPTIONAL)

When smooth_boundary=true, cells near the cylinder boundary receive fractional weights instead of binary inclusion/exclusion. This eliminates sharp grid artifacts while maintaining overall cylindrical geometry:

  • boundary_width=0.1: 10% of radius/height used for smooth transition (default)
  • boundary_width=0.05: 5% transition (sharper but still smooth)
  • Cells well inside: weight = 1.0 (full inclusion)
  • Cells in transition zone: weight = smooth function (0.0 to 1.0)
  • Cells well outside: weight = 0.0 (excluded)

The default behavior uses sharp boundaries for backward compatibility.

Returns

  • HydroDataType: New hydro data object containing filtered cells
  • When smooth_boundary=true, adds cylinder_weight column for boundary cells with smooth transitions

Examples

# Default cylindrical selection (sharp boundaries)
subregion = subregioncylinder(gas,
    radius=5., height=4., center=[:boxcenter],
    range_unit=:kpc, direction=:z)

# Enhanced smooth boundary selection (eliminates grid artifacts)
smooth_subregion = subregioncylinder(gas,
    radius=5., height=4., center=[:boxcenter],
    range_unit=:kpc, direction=:z,
    smooth_boundary=true)

# Custom smooth transition width
fine_subregion = subregioncylinder(gas,
    radius=5., height=4., center=[:boxcenter],
    range_unit=:kpc, direction=:z,
    smooth_boundary=true, boundary_width=0.05)  # 5% transition zone

See Also

  • subregioncuboid: Rectangular subregions
  • subregionsphere: Spherical subregions
  • subregion: Unified interface for all geometries
Mera.subregioncylinderMethod
subregioncylinder(dataobject::RtDataType; kwargs...)

Select a cylindrical subregion from RT data using AMR-aware filtering.

This function extracts all RT cells that lie within or intersect a specified cylindrical region. The cylinder is defined by a radius, height, center position, and orientation axis. It supports both cell-based and point-based selection modes for precise boundary handling.

Arguments

  • dataobject::RtDataType: Input RT data object from getrt()

Keywords

  • radius::Real=0.: Cylinder radius in units specified by range_unit
  • height::Real=0.: Total cylinder height (extends ±height/2 from center plane)
  • center::Array{<:Any,1}=[0., 0., 0.]: Cylinder center position
  • range_unit::Symbol=:standard: Units (:standard, :kpc, :Mpc, etc.)
  • direction::Symbol=:z: Cylinder axis orientation (:x, :y, or :z)
  • cell::Bool=true: Cell-based (true) vs point-based (false) selection mode
  • inverse::Bool=false: Select outside the region instead of inside
  • verbose::Bool=verbose_mode: Print progress information

Selection Modes

  • Cell-based (cell=true): Includes cells that intersect the cylinder boundary
  • Point-based (cell=false): Includes only cells whose centers lie within the cylinder

Returns

  • RtDataType: New RT data object containing filtered cells

Examples

# Select 5 kpc radius, 4 kpc height cylinder along z-axis
subregion = subregioncylinder(rt,
    radius=5., height=4., center=[:boxcenter],
    range_unit=:kpc, direction=:z)

# Disk selection (very thin cylinder)
disk = subregioncylinder(rt,
    radius=10., height=0.5, center=[24., 24., 24.],
    range_unit=:kpc, direction=:z)

See Also

  • subregioncuboid: Rectangular subregions
  • subregionsphere: Spherical subregions
  • subregion: Unified interface for all geometries
Mera.subregionsphereMethod
subregionsphere(dataobject::GravDataType; kwargs...)

Select a spherical subregion from gravity data using AMR-aware filtering.

This function extracts all gravity cells that lie within or intersect a specified spherical region. The sphere is defined by a radius and center position. It supports both cell-based and point-based selection modes for precise boundary handling in AMR simulations.

Arguments

  • dataobject::GravDataType: Input gravity data object from getgravity()

Keywords

  • radius::Real=0.: Sphere radius in units specified by range_unit
  • center::Array{<:Any,1}=[0., 0., 0.]: Sphere center position
  • range_unit::Symbol=:standard: Units (:standard, :kpc, :Mpc, etc.)
  • cell::Bool=true: Cell-based (true) vs point-based (false) selection mode
  • inverse::Bool=false: Select outside the region instead of inside
  • verbose::Bool=verbose_mode: Print progress information

Selection Modes

  • Cell-based (cell=true): Includes cells that intersect the sphere boundary
  • Point-based (cell=false): Includes only cells whose centers lie within the sphere

Returns

  • GravDataType: New gravity data object containing filtered cells

Examples

# Select 10 kpc radius sphere centered at box center
subregion = subregionsphere(gravity,
    radius=10., center=[:boxcenter], range_unit=:kpc)

# Small sphere at specific coordinates
subregion = subregionsphere(gravity,
    radius=2., center=[0.3, 0.4, 0.5], range_unit=:standard)

# Everything outside a 5 kpc sphere (inverse selection)
subregion = subregionsphere(gravity,
    radius=5., center=[24., 24., 24.], range_unit=:kpc, inverse=true)

See Also

  • subregioncuboid: Rectangular subregions
  • subregioncylinder: Cylindrical subregions
  • subregion: Unified interface for all geometries
Mera.subregionsphereMethod
subregionsphere(dataobject::HydroDataType; kwargs...)

Select a spherical subregion from hydro data using AMR-aware filtering.

This function extracts all hydro cells that lie within or intersect a specified spherical region. The sphere is defined by a radius and center position. It supports both cell-based and point-based selection modes for precise boundary handling in AMR simulations.

Arguments

  • dataobject::HydroDataType: Input hydro data object from gethydro()

Keywords

  • radius::Real=0.: Sphere radius in units specified by range_unit
  • center::Array{<:Any,1}=[0., 0., 0.]: Sphere center position
  • range_unit::Symbol=:standard: Units (:standard, :kpc, :Mpc, etc.)
  • cell::Bool=true: Cell-based (true) vs point-based (false) selection mode
  • inverse::Bool=false: Select outside the region instead of inside
  • verbose::Bool=verbose_mode: Print progress information

Selection Modes

  • Cell-based (cell=true): Includes cells that intersect the sphere boundary
  • Point-based (cell=false): Includes only cells whose centers lie within the sphere

Returns

  • HydroDataType: New hydro data object containing filtered cells

Examples

# Select 10 kpc radius sphere centered at box center
subregion = subregionsphere(gas,
    radius=10., center=[:boxcenter], range_unit=:kpc)

# Small sphere at specific coordinates
subregion = subregionsphere(gas,
    radius=2., center=[0.3, 0.4, 0.5], range_unit=:standard)

# Everything outside a 5 kpc sphere (inverse selection)
subregion = subregionsphere(gas,
    radius=5., center=[24., 24., 24.], range_unit=:kpc, inverse=true)

See Also

  • subregioncuboid: Rectangular subregions
  • subregioncylinder: Cylindrical subregions
  • subregion: Unified interface for all geometries
Mera.subregionsphereMethod
subregionsphere(dataobject::RtDataType; kwargs...)

Select a spherical subregion from RT data using AMR-aware filtering.

This function extracts all RT cells that lie within or intersect a specified spherical region. The sphere is defined by a radius and center position. It supports both cell-based and point-based selection modes for precise boundary handling in AMR simulations.

Arguments

  • dataobject::RtDataType: Input RT data object from getrt()

Keywords

  • radius::Real=0.: Sphere radius in units specified by range_unit
  • center::Array{<:Any,1}=[0., 0., 0.]: Sphere center position
  • range_unit::Symbol=:standard: Units (:standard, :kpc, :Mpc, etc.)
  • cell::Bool=true: Cell-based (true) vs point-based (false) selection mode
  • inverse::Bool=false: Select outside the region instead of inside
  • verbose::Bool=verbose_mode: Print progress information

Selection Modes

  • Cell-based (cell=true): Includes cells that intersect the sphere boundary
  • Point-based (cell=false): Includes only cells whose centers lie within the sphere

Returns

  • RtDataType: New RT data object containing filtered cells

Examples

# Select 10 kpc radius sphere centered at box center
subregion = subregionsphere(rt,
    radius=10., center=[:boxcenter], range_unit=:kpc)

# Small sphere at specific coordinates
subregion = subregionsphere(rt,
    radius=2., center=[0.3, 0.4, 0.5], range_unit=:standard)

# Everything outside a 5 kpc sphere (inverse selection)
subregion = subregionsphere(rt,
    radius=5., center=[24., 24., 24.], range_unit=:kpc, inverse=true)

See Also

  • subregioncuboid: Rectangular subregions
  • subregioncylinder: Cylindrical subregions
  • subregion: Unified interface for all geometries
Mera.synthetic_clumpsMethod
synthetic_clumps(; seed=1, lmax=7, background=:floor, noise=0.0,
                   disk_amp=14.0, disk_hr=0.22, disk_hz=0.10) -> NamedTuple

Build a reproducible, data-free 3-D Mera test bench with a known clump population — no simulation files required. Returns (; gas, particles, truth, info, true_label):

  • gas — a HydroDataType: eight Gaussian density clumps spread through the 2^lmax³ volume (box = 1 kpc), with per-cell velocities and pressure.
  • particles — a PartDataType: one particle bag per clump plus a two-component kinematic stream (for PhaseSpaceFoF).
  • truth — the ground-truth catalog (id, name, kind, pos, mass, width, vsig, bound).
  • true_labeltrue_label(x,y,z)::Int, the dominant clump id at a position (0 = background).

The data and all finders are fully three-dimensional; the clumps sit at different z, including a touching pair and a kinematically-hot unbound clump. The same eight clumps can be embedded in different environments to test how well a finder separates them from the floor:

  • background=:floor (default) — a flat low background; clumps are isolated islands.
  • background=:galaxy — clumps embedded in a smooth exponential ISM disk (disk_amp, radial/vertical scales disk_hr/disk_hz) whose inner region is itself elevated, so a fixed low threshold captures the diffuse disk as a spurious structure.
  • noise>0 — multiplicative log-normal per-cell fluctuations (turbulent ISM); noise is the dispersion of ln ρ (e.g. 0.2).

Either non-default option fills the whole grid (use lmax=6 to keep it fast). The clump ground truth is unchanged — the background is labelled 0, so a finder that absorbs the floor into its clumps is penalised by clump_recovery.

F = synthetic_clumps()
cat = clumpfind(F.gas, ThresholdFoF(:rho; threshold=5.0, linking_length=2.0/2^7))

See also save_synthetic_clumps, load_synthetic_clumps, and the "Clump Finding — Synthetic Example" documentation page.

Mera.throughput_testMethod
throughput_test(files; runs=1, N=5, levels=[1,2,4,8,16,24,32,48,64])

Reads N files and measures the mean per-file (single-stream) read rate in MB/s per thread count — not summed aggregate bandwidth. Returns (samples, stats, elapsed).

Mera.timed_notifyMethod

Track execution time and send notification with timing information

Convenience function that automatically tracks execution time of a code block and sends a notification with timing details.

Parameters:

  • task_name: Description of the task being timed
  • code_block: Function or code to execute and time
  • zulip_channel: Zulip channel for notification (default: "timing")
  • zulip_topic: Zulip topic for notification (default: "Execution Times")
  • include_details: Include detailed performance metrics (default: false)

Examples:

# Time a function execution
timed_notify("Data processing", () -> process_large_dataset())

# Time with detailed metrics
timed_notify("Complex analysis", () -> analyze_galaxy_formation(), 
             include_details=true, zulip_channel="research")

# Time with custom messaging
timed_notify("Simulation run #47", () -> run_simulation(params), 
             zulip_channel="simulations", zulip_topic="Run Times")
Mera.timerfileMethod

Get a printout of the timerfile:

timerfile(object::InfoType)
Mera.timeseriesMethod
timeseries(path, reducer; kwargs...)

Run reducer on every snapshot of a simulation and collect the results into a single table — one row per output, ordered by output number.

reducer receives the loaded data object of one snapshot and returns either a scalar or a NamedTuple. The returned table always carries an output column and a time column (physical time in Myr by default, from gettime; a cosmological run additionally gets redshift and aexp columns). A scalar reducer value lands in a value column, a NamedTuple is expanded into one column per field.

Snapshots are loaded strictly one at a time and released before the next, so memory stays bounded — suited to a laptop with limited RAM. Loading respects JULIA_NUM_THREADS (cap it at 4 on a laptop); snapshots are processed sequentially.

Arguments

  • path::String : simulation directory (folder holding output_xxxxx/ for RAMSES, or output_xxxxx.jld2 mera files when mera_files=true).
  • reducer : function data -> scalar | NamedTuple.

Keywords

  • datatype::Symbol = :hydro : :hydro, :gravity, :particles, :clumps, or :rt.
  • outputs = :all : :all, a range (1:10), or an explicit vector of output numbers. Numbers not present on disk are skipped.
  • mera_files::Bool = false : load mera (JLD2) files via loaddata instead of raw RAMSES outputs.
  • loader = nothing : custom info -> data to fully control loading (overrides datatype/ranges/lmax). Use e.g. loader = info -> gethydro(info, [:rho]; lmax=6).
  • lmax = nothing : max AMR level to read (hydro/gravity); nothing uses info.levelmax.
  • xrange, yrange, zrange, center, range_unit : spatial selection passed to the loader — cutting the region is the main lever to reduce RAM per snapshot.
  • time_unit::Symbol = :Myr : unit for the time column — physical by default (:Myr/:Gyr/…); pass :standard for code units (see gettime). A cosmological run also gets redshift and aexp columns automatically.
  • verbose::Bool = true : print per-snapshot progress.
  • notify::Bool = false : call notifyme when finished (a no-op unless ~/email.txt / ~/zulip.txt is configured).

Examples

# evolution of total gas mass and peak density across all outputs
ts = timeseries("/data/sim/timeseries_sedov3d", d -> (
        mass    = msum(d, :Msol),
        rho_max = maximum(getvar(d, :rho)),
     ))

# same, but from mera files and only every region of interest (less RAM)
ts = timeseries("/data/sim/timeseries_sedov3d_mera",
                d -> msum(d, :Msol);
                mera_files=true, xrange=[0.4,0.6], yrange=[0.4,0.6], zrange=[0.4,0.6])

See also checkoutputs, gettime, gethydro, loaddata.

Mera.update_progress!Function

Update progress tracker and send notifications if thresholds are met

Parameters:

  • tracker: Progress tracker created by createprogresstracker()
  • current_item: Current item number being processed
  • custom_message: Optional custom message for this update

Examples:

tracker = create_progress_tracker(1000, task_name="Data analysis")

for i in 1:1000
    analyze_data_point(i)
    update_progress!(tracker, i)
    
    # Optional: Add custom message for specific milestones
    if i == 500
        update_progress!(tracker, i, "Reached halfway point - results looking good!")
    end
end
Mera.update_progress!Method
update_progress!(tsp::ThreadSafeProgress, filename::String)

Thread-safe function to update progress bar with current file information. Uses locking to prevent race conditions when multiple threads update simultaneously.

Thread Safety

  • Acquires exclusive lock before any modifications
  • Updates both counter and description atomically
  • Releases lock automatically when function exits
  • Prevents progress bar corruption from concurrent updates

Display Format

  • Shows [completed/total] ratio
  • Displays currently processing filename
  • Updates speed calculation automatically
Mera.usedmemoryFunction
usedmemory(object, verbose::Bool=true)
usedmemory(obj_value::Real, verbose::Bool=true)

Calculate and display memory usage of an object or raw byte value in human-readable units.

Arguments

  • object: Any Julia object whose memory usage should be calculated
  • obj_value::Real: Raw memory size in bytes
  • verbose::Bool=true: Whether to print the result to console

Returns

  • value::Float64: Memory usage value in the appropriate unit
  • unit::String: Unit string ("Bytes", "KB", "MB", "GB", or "TB")

Examples

# Check memory usage of a data object
data = rand(1000, 1000)
value, unit = usedmemory(data)  # Prints: "Memory used: 7.629 MB"

# Silent calculation
value, unit = usedmemory(data, false)  # Returns (7.629, "MB") without printing

# Direct byte value
value, unit = usedmemory(1048576, false)  # Returns (1.0, "MB")
Mera.velocity_cubeMethod
velocity_cube(dataobject; nv=64, vrange=nothing, v_unit=:km_s, <los_cube kwargs>) -> LosCubeType

Convenience wrapper of los_cube with quantity=:vlos — a velocity-channel (spectral) cube. The result exposes .velocity (= .bins) and .v_unit aliases.

Mera.velocity_momentsMethod
velocity_moments(vc::LosCubeType) -> (Σ, vlos, σlos)

Velocity-cube moments: column mass Σ, mass-weighted mean line-of-sight velocity vlos, and dispersion σlos — i.e. the :sd/:mass, :vlos and :σlos maps recovered from the cube.

Mera.velocitydispersionMethod
velocitydispersion(dataobject; rvar=:r_cylinder, components=(:vr_cylinder,:vϕ_cylinder,:vz),
                   weight=:mass, vunit=:km_s, nbins=50, xrange=nothing, scale=:linear, binsize=nothing,
                   center=[:bc], center_unit=:standard, xunit=:kpc, mask=[false],
                   thermal=false, mu=1.0, Tvar=:T) -> NamedTuple

Radial velocity-dispersion profile. Bins by rvar and returns the per-bin weighted standard deviation of each velocity component — the rest-frame dispersion (about the per-bin mean, so net rotation/streaming does NOT inflate it) — plus the total σ = √(σ₁²+σ₂²+σ₃²) and each component's mean. The default cylindrical triplet gives σR / σφ / σz (use `(:vrsphere,:vθsphere,:vϕsphere)for the spherical decomposition). Each σ is exactly thestdof [profile`](@ref) on that component — this is a convenience wrapper; see the profiles tutorial for the manual recipe.

Returns x (bin centres), edges, count, sigma (total), sigma_components (nbins × n) and mean_components (nbins × n) with the components order, and neff (Kish — small ⇒ noisy σ).

Thermal & total dispersion (thermal=true). The kinematic σ above is turbulent (bulk) motion only. Set thermal=true to also fold in the gas thermal motion and report the quantity an observer measures as a line width. It adds, per bin:

  • sigma_turb_1d = √(Σσ_i²/n) — the 1-D turbulent dispersion (the sigma field is the 3-D √(Σσ_i²));
  • sigma_thermal = √(k_B⟨T⟩/(μ m_H)) — the 1-D thermal speed of a tracer of mean molecular weight mu (in H-atom masses; e.g. mu=2.33 molecular, 1.0 atomic H, 0.6 ionized), from the mass-weighted ⟨T⟩;
  • sigma_total = √(sigma_turb_1d² + sigma_thermal²) — the total (turbulent ⊕ thermal) 1-D dispersion;
  • mach = sigma_turb_1d / ⟨c_s⟩ — the turbulent Mach number (⟨c_s⟩ the mass-weighted sound speed);
  • cs, T, mu — the per-bin mass-weighted sound speed / temperature and the mu used.

Tvar selects the temperature field (default :T). For a local, patch-de-streamed turbulent ⊕ thermal dispersion (TIGRESS/SILCC-style, removing bulk flow on a chosen length scale rather than per-radial-bin), see localdispersion.

What kind of dispersion this is (3-D, per-annulus)

This is the 3-D, per-bin dispersion: all cells in a radial bin, variance of the velocity component about the single per-bin mean. The bin-mean rotation/streaming is removed, but a velocity gradient across the bin (e.g. the rotation curve varying over the annulus width, a warp, or vertical structure binned only in radius) is not — by the law of total variance σ²_bin = ⟨σ²_local⟩ + Var[⟨v⟩_local], this σ also carries the intra-bin shear term, so it is an upper bound on the local random dispersion. Shrink the bins, or bin in 2-D/3-D (profile3d/phase in R and z or azimuth), to localise it.

For a local, per-pixel dispersion of the line-of-sight velocity instead, use the projected map projection(obj, :σlos) (or los_moments/los_component(...; dispersion=true)) and profile it (profile(proj, :σlos; xvar=:r, weight=:sd)). There σ = √(⟨v²⟩−⟨v⟩²) is taken about each pixel's own mean (the local bulk/rotation velocity is removed per pixel), so it is locally rest-frame; it still includes sub-pixel / along-the-line-of-sight ordered motion (beam smearing). Note these two are also physically different quantities — a 3-D velocity component vs a projected line-of-sight dispersion.

Mera.verboseMethod
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 control
Mera.viewallfieldsMethod

Get a detailed overview of many fields from the MERA InfoType:

viewallfields(dataobject::InfoType)
Mera.viewdataMethod

Get overview of stored datatypes:

  • compression
  • versions of the used/loaded compression
  • MERA/MERA-file version
  • compressed/uncompressed data size
  • returns stored conversion statistics, when available (created by convertdata-function)
function viewdata(output::Int;
        path::String="./",
        fname = "output_",
        showfull::Bool=false,
        verbose::Bool=true)

return overview (dictionary)

Arguments

Required:

  • output: output number
  • datatype: :hydro, :particles, :gravity, :clumps or :rt

Predefined/Optional Keywords:

  • 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"
  • showfull: shows the full data tree of the datafile
  • verbose:: informations are printed on the screen by default
Mera.viewfieldsMethod

Get an overview of the fields from MERA composite types:

viewfields(object)
Mera.viewmoduleMethod

Get a list of all exported Mera types and functions:

function viewmodule(modulename::Module)
Mera.wstatMethod

Calculate statistical values w/o weighting of any Array:

wstat(array::Array{<:Real,1}; weight::Array{<:Real,1}=[1.], mask::MaskType=[false])

WStatType(mean, median, std, skewness, kurtosis, min, max)

Arguments

Required:

  • array: Array needs to be of type: "<:Real"

Optional Keywords:

  • weight: Array needs to be of type: "<:Real" (can be used w/o keyword)
  • mask: needs to be of type MaskType which is a supertype of Array{Bool,1} or BitArray{1} with the length of the Array
Mera.wstat_metaprogMethod

Metaprogramming-optimized statistical functions with template generation. Generates specialized code for different weighting and masking combinations.