Masking & Filtering API Reference
Docstrings for selecting a subset of cells or particles by value. The narrative guide is Mask/Filter/Meta.
Two routes exist. getmask returns a boolean array you pass to other functions; filterdata returns a new data object you can keep chaining. Conditions are built from FilterCondition values such as Above and InRange, and combine with &, | and !.
Value-space selection
Mera.filterdata — Function
filterdata(obj, condition...; verbose=true) -> same-type Mera object
filterdata(obj, quantity, predicate; unit=:standard, verbose=true) -> same-type Mera objectSelect 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 objectMera.getmask — Function
getmask(obj, condition) -> BitVector
getmask(obj, quantity, predicate; unit=:standard) -> BitVectorBuild 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.
Conditions
Mera.FilterCondition — Type
FilterConditionSupertype of the composable value-space selectors passed to getmask / filterdata: Above, Below, InRange. Combine them with & (and), | (or) and ! (not) — e.g. Above(:T, 1e4; unit=:K) & Below(:rho, 100; unit=:nH).
Mera.Above — Type
Above(quantity, value; unit=:standard)Keep rows where getvar(obj, quantity, unit) > value.
Mera.Below — Type
Below(quantity, value; unit=:standard)Keep rows where getvar(obj, quantity, unit) < value.
Mera.InRange — Type
InRange(quantity, lo, hi; unit=:standard)Keep rows where lo ≤ getvar(obj, quantity, unit) ≤ hi.
Mera.AbovePercentile — Type
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.BelowPercentile — Type
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.Satisfies — Type
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).
Table macros
These operate on the underlying table rather than on Mera quantities, so they see stored columns only — use filterdata when you need a derived quantity such as :T or :v.
Mera.@filter — Macro
@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.@apply — Macro
Find examples in the Mera Documentation for: filter data with pipeline macros
Mera.@where — Macro
Find examples in the Mera Documentation for: filter data with pipeline macros
Related
Spatial selection is a different mechanism, documented in the Subregions API: subregion and shellregion cut by geometry, not by value. Extracting a quantity is getvar, in the Calculations API.
Every docstring in the package is also on the Complete API Reference.