C++ reference¶
Generated from the public headers bitvf/VoidFinder.h, bitvf/BitVF.h
and bitvf/io.h by Doxygen, with only what carries a comment included.
bitvf/BitVF.h includes bitvf/VoidFinder.h; bitvf/io.h is included
separately. Types of otswap in the signatures are documented in otswap’s
reference.
bitvf/VoidFinder.h¶
Errors¶
-
class Error : public std::runtime_error¶
Base class of every exception bitvf throws on invalid input or failure. std::bad_alloc is not converted, and propagates unchanged. An error raised by otswap inside a bitvf call, an otswap::Error or an exception derived from it, reaches the caller as an Error whose message is “otswap: “ followed by its own, with the original nested in it (std::throw_with_nested), so std::rethrow_if_nested recovers it. Catching Error therefore catches every error of a bitvf call.
Error is not derived from otswap::Error: the two are unrelated, and a handler for otswap::Error does not catch it.
An Error records where it was constructed: the source file, the function and the line. The location is not part of what(), which holds the message alone. An error rethrown with context, after a parallel region or from an otswap call, carries the location of the rethrow.
Public Functions
-
inline explicit Error(const std::string &what, const char *file = __builtin_FILE(), const char *function = __builtin_FUNCTION(), int line = __builtin_LINE())¶
- Parameters:
what – the message, returned by what()
file, function, line – the location; left to their defaults, they are those of the expression that constructs the Error
-
inline const char *file() const noexcept¶
- Returns:
the source file in which the Error was constructed, as the compiler named it.
-
inline explicit Error(const std::string &what, const char *file = __builtin_FILE(), const char *function = __builtin_FUNCTION(), int line = __builtin_LINE())¶
Array layout¶
Configuration¶
-
enum class bitvf::LengthUnit¶
Unit of a length the user chooses.
Values:
-
enumerator Mps¶
Multiples of the mean particle separation: the box mps, or in a lightcone mps(z) at each cell’s redshift.
-
enumerator Coordinate¶
The same length unit as the tracer coordinates.
-
enumerator Mps¶
-
struct Smoothing¶
Gaussian smoothing of the divergence field before the watershed.
Each cell takes the weighted mean of the divergence of the cells around it, itself included. The weight of a cell is its tracer weight (DivergenceGrid::weight) times exp(-r^2 / (2 sigma^2)), r the distance between the two cell centres. A cell whose weights sum to at most 1e-12 times the largest tracer weight of the grid takes 0; this includes a filled cell (weight 0) whose surrounding cells hold no weight. A larger sigma merges small basins into larger ones; sigma = 0 disables the smoothing. With sigma > 0 the smoothed field and the smoothed weight are kept beside the divergence and the weight (DivergenceGrid::divergenceSmoothed, weightSmoothed).
Box: the cells around are those within floor(3.5 sigma / s) cells along each axis, s the cell side, cut at the faces of the grid: a cube, not a sphere. When 3.5 sigma / s lies within 1e-9 relative of an integer, that integer is taken instead, so that a cell side rounded by one ulp gives the same cube. Below sigma = s / 3.5 the cube holds the cell alone. In Mps, sigma is multiplied by the box mps.
Lightcone: the cells around are those whose centre lies closer than 4 sigma, with the same weights. Masked cells (DivergenceGrid::masked) enter no mean and take 0. In Mps, sigma is multiplied by mps(z) at the redshift of the centre of the shell of the cell being smoothed.
Public Members
-
double sigma = 1.¶
Width of the Gaussian, in unit; must be finite and non-negative. 1 mps is a reasonable starting value. A positive sigma must be between about 1e-162 and 1e154 in coordinate units; use 0 to disable the smoothing.
-
LengthUnit unit = LengthUnit::Mps¶
Unit of sigma.
-
double sigma = 1.¶
-
struct Config¶
Free parameters of the void finder.
Nothing here depends on the geometry: the inputs proper to a lightcone (mask, distance table, mps(z) profile) are arguments of the lightcone functions. Voids and overdense basins are always both found.
Public Members
-
std::optional<double> divergenceCellSize¶
Side of the divergence-grid cell, in units of the mean particle separation: the box mps, or in a lightcone mps(z) at each shell. Empty: min(1, (20 / nRealizations)^(1/3)), that is 1 up to 20 realizations and (20 / nRealizations)^(1/3) above, the same rule in both geometries. A search on a mean displacement file runs with one realization, so its default is 1. Must be positive when set, and left empty when a grid is reused. Result::config holds the value used. Unrelated to otswap::Config::cellSize, the cell of the neighbour search of the reconstruction, which affects speed only: this one changes the result.
-
bool keepDivergence = false¶
Fill Result::divergence with the grid and the divergence field. Off by default: it holds one entry per cell in several arrays.
-
bool keepAssignment = false¶
Fill Result::assignment, where each tracer ended up. Off by default: it holds one entry per tracer in several arrays.
-
unsigned nRealizationsMean = 1¶
Realizations averaged into each displacement given: 1 for the displacements of single realizations; for the displacements of a mean displacement file, the NREC of that file. A record only, written as the keyword NRECMEAN of bitvf’s files; no computation reads it. Must be at least 1.
-
otswap::Verbosity verbosity = otswap::Verbosity::Normal¶
What the call reports, at otswap’s levels; each line starts with “bitvf: “ and ends in ‘
’.
Silent: nothing.
Normal: the selection, then one line per call with its time:
The box line is written when the search has box limits: those given, the reconstruction’s (otswap::SelectionCounts::boxLimits) or the grid’s (DivergenceGrid::limits); the grid line whenever a grid is reused, even with no tracer outside it, and by findVoidsBoxFromDivergence, as “outside the divergence grid”. The moved line is written by the overload on a reconstruction without box limits, when <m> is not 0: a tracer outside the measured box by rounding is moved onto its edge. <W> counts the tracers read without a valid displacement. A count of 1 takes the singular.bitvf: kept <k> of <N> tracers: <b> outside the box [<x0>, <x1>] x [<y0>, <y1>] x [<z0>, <z1>] bitvf: kept <k'> of <k> tracers: <g> outside the reused grid bitvf: moved <m> tracer(s) onto the box edge bitvf: findVoidsBox: <V> voids and <O> overdense basins from <N> tracers in <T> s; <W> without a valid displacement bitvf: findVoidsBoxFromDivergence: <V> voids and <O> overdense basins from <N> tracers in <T> s bitvf: findVoidsBoxFromField: <V> voids and <O> overdense basins on <nx> x <ny> x <nz> cells in <T> s
In a lightcone, the lines are:
The redshift cut appears in the selection lines only when it has a finite bound; the grid line adds “, central sphere included” when the grid has one, its source is default, given or reused, and it ends “(from the tracers and randoms)” or “(from the reused grid)”; the reused-grid line is written whenever a grid is reused; the masked-cell, divergence and fill lines only when <n>, <r> or <e> is not 0 (Counts::tracersInMaskedCells, displacementsRejected). The call line names findVoidsLightconeFromCartesian for that function; <W> counts the tracers kept and inside the grid without a valid displacement.bitvf: kept <k> of <N> tracers: <m> on unobserved pixels, <c> outside the redshift cut bitvf: kept <k> of <M> randoms: <m> on unobserved pixels, <c> outside the redshift cut bitvf: grid of <C> cells in <S> shells, cell size <s> mps (<source>), distances [<d0>, <d1>], RA [<a0>, <a1>] deg, Dec [<b0>, <b1>] deg (<from>) in <t> s bitvf: kept <k'> of <k> tracers: <g> outside the reused grid bitvf: <n> tracers start in a masked cell, in no basin bitvf: divergence of the valid displacements of <u> tracers, <r> displacements rejected (masked cells, outside or below the grid) in <t> s bitvf: filled <f> cells in <p> passes, <e> left empty in <t> s bitvf: findVoidsLightcone: <V> voids and <O> overdense basins from <N> tracers in <T> s; <W> without a valid displacement
Detailed: as Normal, with one line per step of the search in the order it runs, each with its time, and the values that describe it: the mean particle separation and its source, the grid, its cell side and the box it covers, the smoothing sigma, the basins found by the watershed.
Each line is written as soon as its step finishes, by the calling thread, never inside a parallel region. A call that throws leaves the lines of the steps it finished, and never writes its call line. Every count printed can be read from the object returned (Result::counts, the catalogues’ nBasins); step times and descriptive values (mps, cell side, box, sigma) appear only in the lines. Times have two decimals.
-
std::ostream *log = &std::clog¶
Where the report is written; null writes nothing, as Silent.
-
std::optional<double> divergenceCellSize¶
Results¶
-
struct Result¶
Output of one void search.
Given the same inputs, every field but elapsedSeconds is the same bit for bit whatever the number of threads.
A result of findVoidsBoxFromField, a field result, holds no tracer: nTracers and nRealizations are 0, which tells it from the result of every other search, and so are the counts; ids, the per-tracer flags, assignment, and the catalogue columns deltaAv, delta2Mps and nTracers are empty; limits is empty; mps is NaN when none was given.
Public Members
-
unsigned nRealizations = 0¶
The realizations the search read; 0 in a result of findVoidsBoxFromField.
-
std::vector<std::int64_t> ids¶
The identity of each input row, as given: any 64-bit integer, negative ones included, each row its own. Empty means no IDs, and the writers then write each row’s index, from 0. Flat, [tracer]; size nTracers or 0. No computation reads it.
-
std::optional<unsigned> randomSeed¶
The seed bitvf derived and used to draw the randoms of a box pipeline given none, which alone reproduces them; empty when bitvf drew no randoms.
-
BasinCatalog voids¶
The voids.
-
BasinCatalog overdense¶
The overdense basins.
-
std::optional<DivergenceGrid> divergence¶
The grid and the divergence field, when Config::keepDivergence is set.
-
std::optional<TracerAssignment> assignment¶
Where each tracer ended up, when Config::keepAssignment is set.
-
std::vector<std::uint8_t> uncorrected¶
Real-space pass of a pipeline with redshift-space correction: 1 for a tracer the correction left unmoved, excluded from the second reconstruction and from this search, row kept. Flat, [tracer]; empty elsewhere, which reads as all 0.
-
std::vector<std::uint8_t> outsideGrid¶
1 for a tracer outside the reused grid, excluded from this search, row kept. In the real-space pass of a pipeline: corrected and, in a lightcone, inside the redshift cut, but outside the first pass’s grid, so excluded from the second reconstruction too. Flat, [tracer]; filled only when a grid was reused, empty elsewhere, which reads as all 0.
-
std::vector<std::uint8_t> outsideCut¶
Real-space pass of a lightcone pipeline with redshift-space correction: 1 for a tracer the correction moved outside the redshift cut, excluded from the second reconstruction and from this search, row kept. Flat, [tracer]; empty elsewhere, which reads as all 0. A tracer carries at most one of uncorrected, outsideCut and outsideGrid, checked in that order.
-
std::optional<otswap::BoxLimits> limits¶
Box: the box limits of the search, the limits given or otswap::SelectionCounts::boxLimits; the tracers outside them were skipped. Empty without limits and in a lightcone.
-
double mps = std::numeric_limits<double>::quiet_NaN()¶
Box: the mean particle separation the search used, in coordinate units: the one given, otswap::Result::mps, or a reused grid’s. NaN in a lightcone.
-
otswap::MpsProfile mpsProfile¶
Lightcone: the mps(z) profile the search used, a reused grid’s when one was given. Empty in a box.
-
std::shared_ptr<const otswap::DistanceTable> distances¶
Lightcone: the distance table of the search; coordinates are in Mpc/h when it comes from otswap’s cosmology. Null in a box.
-
int maskNside = 0¶
Lightcone: the NSIDE of the mask the search was given (otswap::Mask::nside), which the files record. 0 in a box.
-
otswap::RedshiftCut redshiftCut¶
Lightcone: the closed range of observed redshift the search kept, which the files record when a bound is finite. The default cuts nothing, as in a box.
-
double elapsedSeconds = 0.¶
Wall time of the call, in seconds. Two runs on the same inputs give the same result but for this field.
-
unsigned nRealizations = 0¶
-
struct BasinCatalog¶
One catalogue of watershed basins: the voids, or the overdense basins.
The columns are the same for both kinds and in both geometries. Row b is basin b, numbered from 0 in the order of the index of its seed cell, a local minimum of the divergence (smoothed when a smoothing is set): below 0 for a void, at or above 0 for an overdense basin. In a box every cell belongs to exactly one basin, a void or an overdense basin. The order does not depend on the number of threads.
The core of a void is the part of the void where the divergence is below 0; the extended void is the whole basin. In a box the core and the extended basin of an overdense basin coincide, since every cell of a basin has a divergence at or above that of its seed.
Each cell flows to the neighbour where the divergence drops the most (the largest decrease, not divided by the distance), among its neighbours (box: the cells that share a face, an edge or a corner with it; lightcone: the unmasked cells whose centres are closer than r (s_i + s_j) / 2, r = (sqrt(3) + 2) / 2, s_i and s_j the sides of the two cells, about 1.87 times their mean), when that value is strictly below its own; among equal smallest values, the neighbour with the lowest cell index. A cell with no strictly smaller neighbour is a seed, so two adjacent cells of equal value with no smaller neighbour are both seeds. A basin is the seed and every cell whose flow reaches it. In a box the grid is not periodic: a cell on a face has fewer neighbours.
Public Members
-
std::vector<double> centre¶
Cartesian centre, in coordinate units: the seed cell’s centre x0, shifted by s sum_n div_n (x_n - x0) / sum_n |div_n| over the seed’s neighbouring cells n, with div the field the watershed split and s = -1 for a void, +1 for an overdense basin (towards lower divergence in a void, higher in an overdense basin), and kept inside the seed cell. Flat, [basin][xyz].
-
std::vector<double> centreSky¶
Sky coordinates of centre: right ascension, declination, redshift; radians. Flat, [basin][3] in a lightcone; empty in a box.
-
std::vector<double> radius¶
Radius of the sphere with the volume of the core, in coordinate units.
-
std::vector<double> radiusExt¶
Radius of the sphere with the volume of the extended basin, in coordinate units.
-
std::vector<double> deltaAv¶
Mean density contrast of the tracers in the core: the tracers starting in its cells (nTracers) over its volume, divided by the mean density mps^-3 (mps(z)^-3 in a lightcone), minus 1.
-
std::vector<double> delta2Mps¶
Density contrast within 2 mps of the centre, the sphere closed. In a box, n_t over its volume, divided by the mean density mps^-3, minus 1, with n_t the tracers the search reads (inside the limits and the reused grid) in the sphere. In a lightcone, within 2 mps(z) at the centre’s redshift, n_t / (n_r N_t / N_r) - 1, with n_t and n_r the tracers and randoms in the sphere and N_t / N_r one ratio of the tracers to the randoms over the whole search (Counts::randoms); NaN when no random lies in the sphere. The expected count n_r N_t / N_r has a relative noise of about 1 / sqrt(33.5 q f), with q the randoms per tracer and f the fraction of the sphere inside the survey: 30 randoms per tracer, the minimum the reconstruction needs with otswap’s default of 30 realizations, is a reasonable start.
-
std::vector<std::uint8_t> edgeFlag¶
Contact with the boundary: 0 none; 1 only the extended basin touches it; 2 the core already touches it. The boundary is, in a box, the faces of the grid, with or without box limits; in a lightcone, the masked cells (DivergenceGrid::masked) and the border of the grid. In a box, a basin touches the boundary when one of its cells lies on a face of the grid. In a lightcone, when one of its cells shares a face with a masked cell, or lies on the border: the first shell unless it is the central sphere, the last shell, the first and the last declination ring of a shell unless its edge is on a pole, and the first and the last sector of a ring that is not a full circle. A masked cell that touches a basin’s cell only along an edge or at a corner does not count.
-
std::vector<double> contamination¶
Fraction of the basin’s surface that lies on the boundary of edgeFlag. In a box, the faces of its cells on the faces of the grid, over those faces plus the faces its cells share with cells of other basins; 1 for a basin that fills the grid. In a lightcone, the area its cells share with masked cells plus their area on the border, over that area plus the area they share with cells of other basins; 0 when that sum is not positive.
-
std::vector<std::size_t> nTracers¶
Tracers starting in the cells of the core: the count behind deltaAv.
-
std::vector<double> fieldCentre¶
findVoidsBoxFromField only, empty otherwise: the field the watershed split, smoothed when a smoothing was applied, at centre, interpolated trilinearly between the eight nearest cell centres. The point is first clamped, per axis, to the range of the cell centres; an axis with one cell takes that cell’s value. At a cell centre it is that cell’s value.
-
std::vector<double> centre¶
-
struct DivergenceGrid¶
The grid of the void finder and the divergence field on it, one row per cell.
An output: filled in Result::divergence when Config::keepDivergence is set, or read from a divergence file. The void finder takes one back as a grid to reuse. A reuse reads only the fields that define the cells, marked so below, cellSizeMps, and mps or mpsProfile; it checks that they are consistent, and throws Error otherwise. The per-cell results of the search that filled the grid (divergence, weights, counts, basin indices, cell limits), its box limits and its realization counts are ignored, whatever their size. Cell c is row c; basins are ordered by the index of their seed cell.
Box. Cubic cells of side cellSize: cell (i, j, k) spans lower + (i, j, k) * cellSize to lower + (i + 1, j + 1, k + 1) * cellSize on the three axes, and is row (i * nY + j) * nZ + k, with (nX, nY, nZ) = nCellsAxis. The grid is built from the box limits of the call, or without them from the bounding box of the tracers read and of the endpoints of their valid displacements; from a reconstruction, from its box (otswap::Result::box). It is padded by 0.1 mps on each side. With E the padded extent and s the cell side, an axis needs floor(E / s + 1) cells; the largest count is used on all three axes, so the grid is a cube of cells even when the box is not. The padded box is then placed in the cells: on each axis, with n the count and S = n s - E the slack, its lower face moves down by S / 2 and its upper face up by S / 4, so the box lies inside the cells, closer to the upper side. With limits the grid overhangs them.
Lightcone. Cells are numbered by shell, then declination ring, then right-ascension sector. The grid is rebuilt from its construction parameters (distanceMin, distanceMax, raMin, raMax, decMin, decMax, cellSizeMps), its mpsProfile and the distance table of the call, through which each shell’s width is evaluated: it is the same grid only with the same distance table, which nothing checks. The shells start at a central sphere or at a first edge just below distanceMin, and are cellSizeMps * mps(z) wide at their centres until past distanceMax; each is divided into declination rings over the footprint, with polar caps when the footprint comes near a pole, and each ring into right-ascension sectors over the footprint, or over the full circle when the footprint nearly spans it.
The values that define the cells are reproduced bit for bit when the grid is passed back in memory. A divergence file stores them at 17 significant digits, angles in degrees, so a grid read from one equals the built one up to the rounding of its right-ascension and declination edges in a lightcone: a tracer within rounding of such an edge can change cell.
Public Members
-
std::size_t nCells = 0¶
Number of cells.
-
double cellSize = std::numeric_limits<double>::quiet_NaN()¶
Box, defines the cells: cell side, in coordinate units, cellSizeMps times mps. In a result of findVoidsBoxFromField, the spacing (max - min) / (n - 1) of the centres along the axis with the most nodes, x before y before z on a tie, with cellSizeMps that spacing divided by mps. NaN in a lightcone.
-
std::array<double, 3> lower = {std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()}¶
Box, defines the cells: x, y, z of the lower grid face, in coordinate units. NaN in a lightcone.
-
std::array<double, 3> upper = {std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()}¶
Box, defines the cells: x, y, z of the upper face of the padded box as placed, in coordinate units. It lies below the last cell face, lower + nCellsAxis * cellSize; it is stored as built and never recomputed from the other fields. NaN in a lightcone.
-
std::array<std::size_t, 3> nCellsAxis = {0, 0, 0}¶
Box, defines the cells: cells along x, y, z, the same count on the three axes but in a result of findVoidsBoxFromField, where they may differ. 0 in a lightcone.
-
std::optional<otswap::BoxLimits> limits¶
Box: the box limits of the search that filled the grid; the tracers outside them were skipped. Empty without limits and in a lightcone. Not part of the cells: a search reusing the grid does not read it, its own limits apply.
-
unsigned nRealizations = 0¶
The realizations of the search that filled the grid (keyword NREC). A record: a search reusing the grid does not read it. 0 in a grid from boxGrid or lightconeGrid and in a result of findVoidsBoxFromField.
-
unsigned nRealizationsMean = 0¶
Config::nRealizationsMean of the search that filled the grid (keyword NRECMEAN). A record, as nRealizations. 0 in a grid from boxGrid or lightconeGrid and in a result of findVoidsBoxFromField.
-
double distanceMin = std::numeric_limits<double>::quiet_NaN()¶
Lightcone, defines the cells: comoving distance range of the tracers and randoms the grid covers, in coordinate units. NaN in a box.
-
double raMin = std::numeric_limits<double>::quiet_NaN()¶
Lightcone, defines the cells: right-ascension range of the footprint, radians, cut at its largest gap on the circle: raMin, the first value after the gap, lies in [0, 2 pi), and raMax may exceed 2 pi when the footprint crosses RA = 0. NaN in a box.
-
double decMin = std::numeric_limits<double>::quiet_NaN()¶
Lightcone, defines the cells: declination range of the footprint, radians. NaN in a box.
-
double cellSizeMps = std::numeric_limits<double>::quiet_NaN()¶
Config::divergenceCellSize used. In a box, in units of mps, a record of the choice beside cellSize, which is cellSizeMps * mps as built, and which a search reusing the grid reports in Result::config; in a lightcone, in units of mps(z), and it defines the cells.
-
double mps = std::numeric_limits<double>::quiet_NaN()¶
Box: the mean particle separation the grid was built with, in coordinate units; the smoothing in mps and the delta2Mps radius of a search that reuses the grid follow it. NaN in a lightcone, and in a result of findVoidsBoxFromField given no mps (cellSizeMps too).
-
otswap::MpsProfile mpsProfile¶
Lightcone: the mps(z) profile the grid was built with; the shells, the smoothing in mps and the delta2Mps radius of a search that reuses the grid follow it. Empty in a box.
-
std::vector<double> cellRaMin¶
Lightcone, descriptive: the limits of each cell as built, radians and coordinate units; never read by a reuse, empty in a grid from io::readDivergence (io::writeDivergence rebuilds them). Right-ascension edges are continuous across RA = 0 within a ring; a ring of a single sector spans 2 pi. The central sphere, when present, has distance limits [0, r] and the full sky; a polar cap reaches declination pi/2 (or -pi/2) over the full circle. Flat, [cell]; empty in a box.
-
std::vector<double> centre¶
Cartesian centre of each cell, in coordinate units. Flat, [cell][xyz].
-
std::vector<double> centreSky¶
Sky coordinates of each cell centre: right ascension, declination, redshift; radians. Flat, [cell][3] in a lightcone; empty in a box.
-
std::vector<double> divergence¶
The divergence of each cell, before smoothing; what the watershed splits with sigma = 0.
-
std::vector<double> divergenceSmoothed¶
The divergence after smoothing (see Smoothing), what the watershed splits, with sigma > 0; empty with sigma = 0.
-
std::vector<double> volume¶
Volume of each cell, in coordinate units cubed: uniform in a box.
-
std::vector<double> weight¶
Tracer weight of each cell, the weight of the smoothing: nDisplacements / nRealizations where a displacement contributed. A cell that no displacement contributed to (nDisplacements 0) is empty: it keeps a weight of 0, and the fill gives it the mean divergence of nearby cells that hold a value, a contribution or a value filled in an earlier pass, weighted by 1 / r^2, r the distance between the cell centres. The fill runs in passes, each reading the values left by the previous one. With its weight of 0, a filled value enters no smoothed mean; with sigma = 0 the watershed reads it as it is.
Box: the neighbours within one cell along each axis, or within two when fewer than three of those hold a value; the passes repeat until no cell is empty (an Error when a pass fills none).
Lightcone: the neighbouring cells (as BasinCatalog) that hold a value, when at least three do; the passes repeat until one fills no cell. A cell left empty keeps a divergence of 0, and a masked cell is never filled.
-
std::vector<double> weightSmoothed¶
Smoothed tracer weight of each cell, with sigma > 0: the mean of weight over the cells of the smoothing (see Smoothing) with the Gaussian alone as weight, sum K w / sum K, K = exp(-r^2 / (2 sigma^2)). It shows how much of a cell’s smoothed divergence comes from displacements; the watershed does not read it. Box: the sum of K over the cube is the product of the three sums of the 1-D kernel along the axes, each cut at the faces. Empty with sigma = 0.
-
std::vector<std::uint64_t> nDisplacements¶
Displacement ends counted in each cell, before the fill: a valid displacement that leaves its tracer’s cell counts 1 in that cell and 1 in the cell it ends in; one that ends in its tracer’s cell counts 2 there. In a box, a point on a face between two cells belongs to the upper one, and a displacement that starts or ends on a face, an edge or a vertex, or runs along a face, is counted as that of the same tracer moved one ulp into its cell. In a lightcone, displacements rejected count nowhere (Counts::displacementsRejected).
-
std::vector<std::uint64_t> nTracers¶
Tracers starting in each cell.
-
std::vector<std::int64_t> voidIndex¶
Row of the void each cell belongs to in Result::voids; -1 none.
-
std::vector<std::int64_t> overdenseIndex¶
Row of the overdense basin each cell belongs to in Result::overdense; -1 none.
-
std::vector<std::uint8_t> masked¶
Lightcone: 1 when the cell centre falls on an unobserved pixel of the mask of the call. Empty in a box.
-
std::size_t nCells = 0¶
-
struct TracerAssignment¶
Where each input tracer ended up, one row per input row. Filled in Result::assignment when Config::keepAssignment is set.
Public Members
-
std::vector<std::int64_t> cellIndex¶
Row of the cell the tracer starts in; -1 when outside the grid or left out.
-
std::vector<std::int64_t> voidIndex¶
Row of the tracer’s void in Result::voids; -1 none. In a lightcone, a tracer that starts in a masked cell (DivergenceGrid::masked) keeps that cell in cellIndex but is in no basin (Counts::tracersInMaskedCells).
-
std::vector<std::int64_t> overdenseIndex¶
Row of the tracer’s overdense basin in Result::overdense; -1 none.
-
std::vector<double> distance¶
Distance from the centre of the tracer’s basin, its void or its overdense basin, in coordinate units; NaN for a tracer not in a basin (not read by the search).
-
std::vector<std::uint8_t> inMask¶
Lightcone: 0 when the tracer falls on an unobserved pixel of the mask. Empty in a box.
-
std::vector<std::uint8_t> inCut¶
Lightcone: 0 when the tracer lies outside the redshift cut of the search, and so was skipped; all 1 without a cut. Empty in a box.
-
std::vector<std::uint8_t> inBox¶
Box: 0 when the tracer lies outside the box limits, and so was skipped; all 1 without limits.
-
std::vector<std::uint8_t> used¶
1 when at least one valid displacement of the tracer entered the divergence. Empty after findVoidsBoxFromDivergence, which reads no displacement.
-
std::vector<std::int64_t> cellIndex¶
-
struct Counts¶
What the void finder counted: the counts its report prints, with the catalogues’ nBasins (Config::verbosity).
Public Members
-
std::size_t tracers = 0¶
tracers given
-
std::size_t tracersUsed = 0¶
of them, with at least one displacement used
-
std::size_t tracersUncorrected = 0¶
Real-space pass of a pipeline with redshift-space correction: left unmoved by the correction, and excluded (Result::uncorrected).
-
std::size_t tracersOutsideBox = 0¶
Box with limits: outside them, and skipped (TracerAssignment::inBox).
-
std::size_t tracersOutsideGrid = 0¶
Reused grid: outside it, and excluded (Result::outsideGrid). In the real-space pass of a pipeline: corrected and, in a lightcone, inside the redshift cut, but outside the first pass’s grid.
-
std::size_t tracersOutsideCut = 0¶
Real-space pass of a lightcone pipeline with redshift-space correction: corrected, but moved outside the redshift cut, and excluded (Result::outsideCut).
-
std::size_t randoms = 0¶
Lightcone: N_r of delta2Mps, the randoms the search reads: kept by the mask and the redshift cut, and inside the grid. 0 in a box.
-
std::size_t tracersOutsideMask = 0¶
Lightcone: tracers on unobserved pixels of the mask, and so skipped (TracerAssignment::inMask), whether or not they lie inside the redshift cut. 0 in a box.
-
std::size_t tracersOutsideRedshiftCut = 0¶
Lightcone: of the tracers on observed pixels, those outside the redshift cut, and so skipped. Each flag states its own condition: TracerAssignment::inCut is 0 for every tracer outside the cut, masked or not. The counts do not overlap: a tracer both masked and outside the cut is counted in tracersOutsideMask only. 0 in a box.
-
std::size_t randomsOutsideMask = 0¶
Lightcone: randoms on unobserved pixels of the mask, removed, whether or not they lie inside the redshift cut. 0 in a box.
-
std::size_t randomsOutsideRedshiftCut = 0¶
Lightcone: of the randoms on observed pixels, those outside the redshift cut, removed. A random both masked and outside the cut counts only in randomsOutsideMask. 0 in a box.
-
std::size_t tracersInMaskedCells = 0¶
Lightcone: of the tracers read, those on an observed pixel whose cell is masked (its centre falls on an unobserved pixel, DivergenceGrid::masked). They keep their cell in TracerAssignment::cellIndex but are in no basin, and their displacements are rejected. A smaller cell size makes them fewer. At Normal verbosity, when not 0, the search reports them on a line of their own:
0 in a box.bitvf: <n> tracers start in a masked cell, in no basin
-
std::size_t randomsOutsideGrid = 0¶
lightcone, reused grid: randoms outside it, removed
-
std::size_t displacements = 0¶
valid displacements given
-
std::size_t displacementsRejected = 0¶
Lightcone: valid displacements of the tracers read that were rejected (masked cells, outside or below the grid): the start or the end lies in a masked cell, the end lies outside every cell, or, without a central sphere, the path passes closer to the observer than the grid’s first edge. A path through unobserved pixels is the reconstruction’s to reject, with its own mask and threshold. 0 in a box.
-
std::size_t tracers = 0¶
Void finder, box¶
-
Result bitvf::findVoidsBox(const std::vector<double> &tracers, const std::vector<double> &displacement, const std::vector<std::uint8_t> &valid, double mps, const Config &config, const std::optional<otswap::BoxLimits> &limits = std::nullopt, const std::vector<std::int64_t> &ids = {}, const DivergenceGrid *grid = nullptr)¶
Find voids and overdense basins in a box.
The divergence of the displacement field is computed on a grid of cubic cells (DivergenceGrid), smoothed (Config::smoothing) and divided by a watershed into basins around its local minima: the voids, below 0, and the overdense basins, at or above 0 (BasinCatalog). Reports as Config::verbosity describes.
- Parameters:
tracers – Cartesian coordinates of the tracers, the start of their displacements, 3 * nTracers entries.
displacement – displacements, 3 * nRealizations * nTracers entries, [realization][tracer][xyz]; nRealizations is their size over that of tracers, at least 1. A tracer plus its displacement is the random matched to it. Every valid displacement of a tracer the search reads must be finite; the others, and those of the tracers skipped outside the limits, are not read.
valid – validity of each displacement, nRealizations * nTracers entries, [realization][tracer], each 0 or 1; or empty, which means all valid.
mps – mean particle separation, in coordinate units; must be positive. Use otswap::Result::mps of the reconstruction, or the overload below. With grid, it must equal grid->mps.
config – the parameters of the search.
limits – the box limits, or none. Given, the tracers outside them keep their row but are skipped (TracerAssignment::inBox, Counts::tracersOutsideBox), and the grid is built on them. A point on a face is inside. Each bound must be finite, with lower[k] < upper[k]. Without them, the grid covers the tracers and the endpoints of their valid displacements, tracer plus displacement, in every realization, so that displacements from any source can be searched. With them, pass the limits the reconstruction used, or a valid displacement ending outside the grid is an error.
ids – the identity of each tracer, copied into Result::ids: one per tracer, no value twice; or empty.
grid – a grid to reuse, or null to build one. Given, its cells are used, and its mps sets the smoothing in mps and the delta2Mps radius; densities come from this search’s own counts. Tracers outside every cell are excluded (Result::outsideGrid, Counts::tracersOutsideGrid). Result::divergence, when kept, has the reused cells with this search’s values.
- Throws:
Error –
on the arrays: if tracers is empty or its size is not a multiple of three; if the size of displacement is not 3 * nRealizations * nTracers for a whole nRealizations of at least 1 that fits in an unsigned; if valid is neither empty nor of size nRealizations * nTracers, or holds a value other than 0 and 1; if a coordinate of tracers, or a component of a displacement read, is not finite; if ids is neither empty nor of size nTracers, or holds a value twice;
if mps is not finite and positive; if a bound of the limits is not finite, or a lower bound is not below the upper one;
on config: if smoothing.sigma is not finite and non-negative; if divergenceCellSize is set and not finite and positive; if nRealizationsMean is 0; if smoothing.sigma is positive but, in coordinate units (times mps in Mps), below about 1e-162 or above about 1e154, too small or too large to build the kernel;
on grid: if it is not a box grid; if a field that defines the cells is inconsistent: cellSize, mps or cellSizeMps not finite and positive, cellSize not equal to cellSizeMps * mps bit for bit, a bound of lower or upper not finite or lower[k] not below upper[k], a count of nCellsAxis 0 or the three counts different, nCells not their cube, a field of the lightcone set; if config.divergenceCellSize is set; if mps differs from grid->mps, compared bit for bit;
on the data: if the search reads more than 4294967295 tracers, the most the count of delta2Mps supports; if no valid displacement is left to read; with limits or a reused grid, if a valid displacement read ends outside every cell of the grid, which means the arrays do not come from one reconstruction in that box; if the grid would hold more cells than an int64 index can address; if empty cells remain that the fill of the divergence (see DivergenceGrid::weight) cannot reach; if the divergence is 0 or positive in every cell, so that no void can be found.
- Returns:
the voids and overdense basins, with Result::mps set to mps.
-
Result bitvf::findVoidsBox(const otswap::Result &reconstruction, const Config &config, const DivergenceGrid *grid = nullptr)¶
Find voids and overdense basins in a box, from a reconstruction.
As the overload above, with tracers, displacement, valid, mps and ids taken from the reconstruction. The grid is built on otswap::Result::box, the box the reconstruction used: its limits (otswap::SelectionCounts::boxLimits), or without them the bounding box of the tracers and the given randoms (of the tracers alone when the randoms were drawn). Every endpoint otswap computes lies inside it. The tracers flagged in otswap::Result::outsideBox are skipped without being read. Given the same arrays and otswap::Result::box as the limits, the result equals that of the overload above. Reports as Config::verbosity describes.
Without box limits, a tracer rounded just outside the box, as in an ASCII mean file, is moved onto it: on an axis where it lies outside by at most 1e-8 times the larger of its coordinate and the bound, it is put on the lower bound, or on the largest value below the upper one. The displacement is kept. The search and the files written from the result use the moved positions; the report states how many tracers were moved. With box limits, the tracers outside are excluded.
- Parameters:
reconstruction – a box result of otswap::reconstructBox, or the mean of one: the Result read from a mean displacement file by otswap::io::readDisplacementMean (nRealizations 1, nRealizationsMean the number averaged; set Config::nRealizationsMean to it, so that bitvf’s files record it). The box is the file’s box keywords, with or without BOXLIM; a mean file without box keywords holds no box limits and is refused. The divergence is not linear in the displacement, so a search on the mean of R realizations does not give the result of the search on the R realizations.
config – the parameters of the search.
grid – a grid to reuse, or null, as above. Its mps wins over the reconstruction’s without an error; at Detailed verbosity the report states both.
- Throws:
Error – if the reconstruction is not a box result; if it is malformed: nObjects, nRealizations or nRealizationsMean 0, nRealizationsMean above 1 with nRealizations not 1, validRealizations neither empty nor of nObjects entries or holding more than nRealizations * nRealizationsMean, tracers, displacement, valid, outsideBox or ids of a size that does not match them, valid holding a value other than 0 and 1, ids holding a value twice, box missing, with a bound not finite or a lower bound above the upper one, or different from selection.boxLimits when those are set; selection.boxLimits with a bound not finite, a width not finite, or a lower bound not below the upper one; a tracer not flagged in outsideBox lying outside box by more than the tolerance above, or at all when box limits are set; if its mps is not finite and positive and no grid is given; and as above, but for the mps of the grid, which wins over the reconstruction’s. A positive smoothing.sigma in Mps is checked against the mps of the search: the grid’s when given, otherwise the reconstruction’s.
- Returns:
the voids and overdense basins, with Result::mps the mps of the search: the grid’s when given, otherwise the reconstruction’s.
-
Result bitvf::findVoidsBoxFromDivergence(const DivergenceGrid &divergence, const std::vector<double> &tracers, const Config &config, const std::vector<std::int64_t> &ids = {})¶
Find voids and overdense basins in a box from a divergence computed earlier, with the tracers given.
The field before smoothing (DivergenceGrid::divergence) is smoothed with config.smoothing, in units of the grid’s mps, split into basins and catalogued as findVoidsBox does; a different sigma is the usual reason for the call. With the tracers of the search that produced the grid and the same smoothing, the voids, the overdense basins, the smoothed divergence, the smoothed weight and the assignment but its used flags equal that search’s bit for bit, sigma = 0 included. A grid kept in memory (Config::keepDivergence) serves as well as one read from a divergence file (io::readDivergence). Reports as Config::verbosity describes.
The tracers are read as with a reused grid: those outside the grid’s box limits (DivergenceGrid::limits) are skipped (TracerAssignment::inBox, Counts::tracersOutsideBox), those inside but outside every cell are excluded (Result::outsideGrid, Counts::tracersOutsideGrid). The tracers read in each cell are counted; when the grid holds nTracers, every cell’s count must equal it, or the tracers are not those of the field.
No displacement enters this call: TracerAssignment::used is empty, Counts::displacements and Counts::tracersUsed are 0. The grid’s nDisplacements, nRealizations and nRealizationsMean are copied into Result::divergence, Result::nRealizations and Result::config.nRealizationsMean, so the files written from the result record those of the field. Result::limits is the grid’s limits, Result::mps its mps, Result::config.divergenceCellSize its cellSizeMps.
- Parameters:
divergence – a box grid holding the fields that define its cells, divergence and weight, and optionally nTracers, nDisplacements, limits, nRealizations and nRealizationsMean; its other per-cell fields are not read: divergenceSmoothed and weightSmoothed of the result are computed from these with config.smoothing.
tracers – Cartesian coordinates of the tracers, 3 * nTracers entries; at least one.
config – the parameters of the search; divergenceCellSize must be empty.
ids – the identity of each tracer, copied into Result::ids: one per tracer, no value twice; or empty.
- Throws:
Error –
if tracers is empty, its size is not a multiple of three, or a coordinate is not finite; if ids is neither empty nor of size nTracers, or holds a value twice;
on config as findVoidsBox; if divergenceCellSize is set;
on the grid as on a grid to reuse in findVoidsBox (a lightcone grid, or nCellsAxis not equal on the three axes, among others); if divergence or weight does not hold nCells entries, or an entry of either is not finite; if nTracers is neither empty nor of nCells entries; if a bound of its limits is not finite, or a lower bound is not below the upper one;
if smoothing.sigma is positive but too small or too large in coordinate units to build the kernel, as findVoidsBox;
on the tracers: if the search reads more than 4294967295 tracers; if none is left to read; if the count of a cell differs from the grid’s nTracers;
if the smoothed divergence is 0 or positive in every cell, so that no void can be found.
- Returns:
the voids and overdense basins of the divergence smoothed with config.smoothing, with Result::mps the grid’s mps.
-
Result bitvf::findVoidsBoxFromField(const std::vector<double> ¢res, const std::vector<double> &values, const Config &config, const std::vector<double> &weights = {}, std::optional<double> mps = std::nullopt)¶
Find voids and overdense basins in a field given at the centres of the cells of a box lattice, without tracers.
The lattice is inferred from the centres. On each axis, the coordinates are sorted and split into nodes at the gaps larger than half the largest gap; with n nodes from min to max, the spacing is (max - min) / (n - 1). The spacings of the axes with more than one node must agree within 1e-6 relative: the cell side s is the spacing of the axis with the most nodes, x before y before z on a tie, and is DivergenceGrid::cellSize of the result; the other axes keep their own spacing only to place the centres on nodes. Each centre must lie within 1e-6 s of its node on every axis, and each node of the nx * ny * nz must hold exactly one centre. The grid spans min - s / 2 to max + s / 2 on each axis, without padding, with cubic cells of side s; nx, ny, nz need not be equal. The cells of the result are the rows of the lattice, cell (i, j, k) row (i * ny + j) * nz + k, not the rows of the input, and no map back is returned: the order of the input does not change the result. Reports as Config::verbosity describes.
The field is smoothed with config.smoothing, as the divergence of findVoidsBox, with weights as the tracer weight; split into basins at 0 as BasinCatalog describes: seeds below 0 start voids, those at or above 0 overdense basins. A field with another convention, such as a density or a density contrast with voids above 0, must be shifted or flipped before the call. The catalogues hold centre, radius, radiusExt, edgeFlag and contamination as findVoidsBox computes them, on the faces of the inferred grid, and fieldCentre; deltaAv, delta2Mps and nTracers, which need tracers, are empty. Result is a field result (see Result). With Config::keepDivergence, Result::divergence holds the grid, the field as given (divergence) and, with sigma > 0, smoothed (divergenceSmoothed), the weights as given and, with sigma > 0, their smoothed mean (weightSmoothed), the basin indices, the cell centres and volumes; nDisplacements and nTracers are empty.
A bitvf divergence file is valid input, read with io::readField: its cell centres, divergence and weight with the smoothing of the search that wrote it give back that search’s basins. Their centre, radius and radiusExt can differ from that search’s by a few ulp: they are computed from the grid’s lower and s, which are inferred here from the centres read and may differ from the original grid’s by rounding.
- Parameters:
centres – Cartesian coordinates of the cell centres, 3 * nCells entries, [cell][xyz], in any order.
values – the field at each centre, nCells entries, in the order of centres.
config – the parameters of the search. divergenceCellSize must be empty, keepAssignment unset and nRealizationsMean 1: none applies without tracers. Without mps, a positive smoothing.sigma must be in LengthUnit::Coordinate.
weights – the weight of each cell in the smoothing, as DivergenceGrid::weight in findVoidsBox, nCells entries in the order of centres; or empty, which gives every cell the weight 1. Used as given: a cell whose weights sum to at most 1e-12 times the largest weight takes 0 (see Smoothing).
mps – a mean particle separation, in coordinate units, or none. Given, it is the unit of a sigma in LengthUnit::Mps and is recorded in Result::mps, with the cell size in units of it in Result::config.divergenceCellSize.
- Throws:
Error –
on the arrays: if centres is empty, its size is not a multiple of three, or a coordinate is not finite; if values does not hold one entry per centre, or an entry is not finite; if weights is neither empty nor of one entry per centre, or an entry is negative or not finite;
if mps is given and not finite and positive;
on config as findVoidsBox; if divergenceCellSize is set, keepAssignment is set or nRealizationsMean is not 1; if smoothing.sigma is positive in LengthUnit::Mps without mps; if smoothing.sigma is positive but too small or too large in coordinate units to build the kernel, as findVoidsBox; if smoothing.sigma is positive and every weight is 0;
on the lattice: if every axis has one node (a single cell has no side); if the spacings of two axes differ by more than 1e-6 relative; if a centre lies farther than 1e-6 s from its node; if a node holds two centres, or none;
if the field, smoothed when a smoothing is set, is 0 or positive in every cell, so that no void can be found.
- Returns:
the voids and overdense basins of the field, with Result::nTracers 0, and Result::mps the mps given, or NaN without one.
Void finder, lightcone¶
-
Result bitvf::findVoidsLightcone(const std::vector<double> &tracersSky, const std::vector<double> &displacement, const std::vector<std::uint8_t> &valid, const std::vector<double> &randomsSky, const otswap::Mask &mask, const otswap::DistanceTable &distances, const otswap::MpsProfile &mps, const Config &config, const otswap::RedshiftCut &redshiftCut = {}, const std::vector<std::int64_t> &ids = {}, const DivergenceGrid *grid = nullptr)¶
Find voids and overdense basins in a lightcone, from sky positions.
The divergence of the displacement field is computed on a grid of shells in comoving distance, declination rings and right-ascension sectors (DivergenceGrid), smoothed (Config::smoothing) and divided by a watershed into basins around its local minima: the voids, below 0, and the overdense basins, at or above 0 (BasinCatalog). The observer is at the origin. Reports as Config::verbosity describes.
- Selection
A tracer on an unobserved pixel of the mask, or with a redshift outside the redshift cut, keeps its row but is skipped (TracerAssignment::inMask and inCut, Counts::tracersOutsideMask and tracersOutsideRedshiftCut); its displacements are not read. A random on an unobserved pixel or outside the cut is removed (Counts::randomsOutsideMask, randomsOutsideRedshiftCut). Any finite right ascension is accepted and folded into [0, 2 pi).
- Grid
Without grid, it covers the tracers and randoms kept: their range of comoving distance, right ascension and declination. Its cells are Config::divergenceCellSize times mps(z) wide at the centre of each shell. A cell whose centre falls on an unobserved pixel is masked (DivergenceGrid::masked): it holds no divergence and belongs to no basin. A valid displacement whose start or end lies in a masked cell, whose end lies outside every cell, or that passes closer to the observer than the first shell when the grid has no central sphere, is rejected (Counts::displacementsRejected).
- Parameters:
tracersSky – sky positions of the tracers, [tracer][ra, dec, z], radians, z the observed redshift; 3 * nTracers entries. Every row must be finite, with a declination in [-pi/2, pi/2]; the redshift of a row kept must lie inside the distance table.
displacement – Cartesian displacements, in the unit of the distance table, 3 * nRealizations * nTracers entries, [realization][tracer][xyz]; nRealizations is their size over that of tracersSky, at least 1. They start from the tracers’ Cartesian positions, otswap::toCartesian of tracersSky with the distance table. Every valid displacement of a tracer kept must be finite; the others are not read.
valid – validity of each displacement, nRealizations * nTracers entries, [realization][tracer], each 0 or 1; or empty, which means all valid.
randomsSky – sky positions of the randoms, as tracersSky; required. They describe the survey: they set the extent of a new grid with the tracers, and give the expected counts of BasinCatalog::delta2Mps. Pass the randoms of the reconstruction.
mask – the observed pixels of the survey; the mask of the reconstruction, or a stricter one. Result::maskNside records its NSIDE.
distances – the redshift-distance table; coordinates are in its distance unit (Mpc/h when it comes from otswap’s cosmology). Result::distances holds a copy.
mps – the mean particle separation as a function of redshift, otswap::Result::mpsProfile of the reconstruction. It sets the cell size of each shell, a smoothing in Mps, the mean density of deltaAv and the radius of delta2Mps. It must be positive over the redshifts of the tracers and randoms kept. With grid, it must equal the grid’s profile bit for bit.
config – the parameters of the search.
redshiftCut – the closed range of observed redshift searched; the default cuts nothing. Pass the cut of the reconstruction.
ids – the identity of each tracer, copied into Result::ids: one per tracer, no value twice; or empty.
grid – a lightcone grid to reuse, or null to build one. Its cells are rebuilt from the fields that define them (distanceMin, distanceMax, raMin, raMax, decMin, decMax, cellSizeMps, mpsProfile) with the call’s distance table and mask, and its mps profile sets the smoothing in Mps and the densities. Tracers kept but outside every cell are excluded (Result::outsideGrid, Counts::tracersOutsideGrid), randoms outside are removed (Counts::randomsOutsideGrid). config.divergenceCellSize must be empty. Use a grid kept from an earlier search of the same distance table (Config::keepDivergence) to search several catalogues on the same cells.
- Throws:
Error –
on the arrays: if tracersSky or randomsSky is empty or its size is not a multiple of three; if a row is not finite or has a declination outside [-pi/2, pi/2]; if the size of displacement is not 3 * nRealizations * nTracers for a whole nRealizations of at least 1 that fits in an unsigned; if valid is neither empty nor of size nRealizations * nTracers, or holds a value other than 0 and 1; if ids is neither empty nor of size nTracers, or holds a value twice;
if a bound of the redshift cut is NaN or its lower bound exceeds the upper one; if the mps profile is empty, its lists differ in size, an entry is not finite, its redshifts are not strictly increasing or an mps is not positive;
on config as findVoidsBox, and if config.divergenceCellSize is set with a grid;
on grid: if it is not a lightcone grid; if a field that defines the cells is invalid, or a field of a box grid is set; if mps differs from its profile; if the rebuild gives another number of cells than its nCells, which means another distance table or a modified grid;
on the data: if a tracer or random kept has a redshift outside the distance table; if a valid displacement of a tracer kept is not finite; if no tracer, no valid displacement or no random is left after the mask, the cut and a reused grid; if the search reads more than 4294967295 tracers or randoms, the most the counts of delta2Mps support; if the mps profile is not positive over the redshifts the grid spans; if the grid reaches a distance outside the distance table, has a shell with no declination ring or a full ring with no sector (use a smaller cell or a central sphere), or needs more than 2097151 shells, rings or sectors (increase the cell size); if every valid displacement read is rejected; if the divergence is 0 or positive in every unmasked cell, so that no void can be found.
- Returns:
the voids and overdense basins, with Result::geometry Lightcone, Result::mpsProfile the profile of the search (the grid’s when one was given), Result::distances and Result::maskNside set.
-
Result bitvf::findVoidsLightcone(const otswap::Result &reconstruction, const std::vector<double> &randomsSky, const otswap::Mask &mask, const Config &config, const DivergenceGrid *grid = nullptr)¶
Find voids and overdense basins in a lightcone, from a reconstruction.
As findVoidsLightcone from sky positions, with tracersSky, the Cartesian tracers, displacement, valid, ids, the distance table and, without a grid, the mps profile taken from the reconstruction. A tracer is read only if neither otswap::Result::outsideMask nor outsideRedshiftCut flags it and the mask given allows it. The randoms are converted with the reconstruction’s distance table and cut by its redshift cut (otswap::SelectionCounts::redshiftCut). Reports as Config::verbosity describes.
- Parameters:
reconstruction – a lightcone result of otswap::reconstructLightcone, or the mean of one read with otswap::io::readDisplacementMean (set Config::nRealizationsMean to the number averaged, so that bitvf’s files record it).
randomsSky – the randoms of the reconstruction, as in findVoidsLightcone.
mask – the mask of the reconstruction, or a stricter one; it must not allow a tracer the reconstruction left out as masked.
config – the parameters of the search.
grid – a grid to reuse, or null, as in findVoidsLightcone. Its mps profile wins over the reconstruction’s, which is then not read.
- Throws:
Error – if the reconstruction is not a lightcone result; if it lacks tracersSky, distances or, without a grid, its mps profile; if it is malformed: nObjects or nRealizations 0, an array of a size that does not match them, valid holding a value other than 0 and 1, ids holding a value twice, a redshift cut with a NaN bound or a lower bound above the upper one; if it was filtered against a mask of another NSIDE than the mask given; if the mask given allows a tracer flagged in outsideMask; and as findVoidsLightcone from sky positions.
- Returns:
as findVoidsLightcone from sky positions; Result::distances shares the reconstruction’s table.
-
Result bitvf::findVoidsLightconeFromCartesian(const std::vector<double> &tracers, const std::vector<double> &displacement, const std::vector<std::uint8_t> &valid, const std::vector<double> &randoms, const otswap::Mask &mask, const otswap::DistanceTable &distances, const otswap::MpsProfile &mps, const Config &config, const otswap::RedshiftCut &redshiftCut = {}, const std::vector<std::int64_t> &ids = {}, const DivergenceGrid *grid = nullptr)¶
Find voids and overdense basins in a lightcone, with the tracers and randoms given as Cartesian positions, the observer at the origin.
As findVoidsLightcone from sky positions. The sky coordinates of every row are computed first with otswap::toSky and the distance table given: the right ascension folded into [0, 2 pi), the declination, and the redshift at the row’s distance from the origin. They alone decide the mask, the redshift cut and the cell of every tracer and random; the Cartesian positions are those the displacements start from. A position and its sky coordinates can then disagree on a cell only by rounding, for a point within rounding of a cell edge.
Every row must be finite, must not lie at the origin, and must lie within the distance table, rows on unobserved pixels or outside the cut included, since its sky coordinates decide whether it is kept. A table covering a wider redshift range than the catalogue’s is a safe choice.
- Parameters:
tracers – 3 per tracer, x, y, z, in the unit of the distance table
randoms – as tracers, for the randoms; required
displacement, valid, mask, distances, mps, config, redshiftCut, ids, grid – as findVoidsLightcone from sky positions
- Throws:
Error – as findVoidsLightcone from sky positions, and if a row of tracers or randoms is not finite, lies at the origin, or lies at a distance outside the distance table; the message names the object
- Returns:
as findVoidsLightcone from sky positions
Grid, lightcone¶
-
DivergenceGrid bitvf::lightconeGrid(const otswap::Result &reconstruction, const std::vector<double> &randomsSky, const otswap::Mask &mask, std::optional<double> divergenceCellSize = std::nullopt)¶
The grid findVoidsLightcone builds from this reconstruction and these randoms, bit for bit: on the tracers and randoms the search keeps, with the reconstruction’s profile and distance table, so that one grid can be shared by several searches (findVoidsLightcone’s grid), the two passes of a pipeline or a set of mocks.
Only the fields that define the cells are set: geometry, nCells, distanceMin, distanceMax, raMin, raMax, decMin, decMax, cellSizeMps and mpsProfile; every per-cell field is left empty, and nRealizations and nRealizationsMean are 0. The grid passes the checks of a grid to reuse.
- Parameters:
reconstruction, randomsSky, mask – as findVoidsLightcone
divergenceCellSize – the cell size in units of mps, as Config::divergenceCellSize. Empty for the default, min(1, (20 / nRealizations)^(1/3)), nRealizations those of the reconstruction
- Throws:
Error – on every case of the entry of the same overload of findVoidsLightcone, the checks of the displacements included, and of the grid’s construction
- Returns:
the grid, with geometry lightcone
-
DivergenceGrid bitvf::lightconeGrid(const std::vector<double> &tracersSky, const std::vector<double> &randomsSky, const otswap::Mask &mask, const otswap::DistanceTable &distances, const otswap::MpsProfile &mps, double divergenceCellSize, const otswap::RedshiftCut &redshiftCut = {})¶
The grid the sky-position overload of findVoidsLightcone builds, bit for bit: the same selection of the tracers and randoms, as the overload above, without displacements.
- Parameters:
tracersSky, randomsSky, mask, distances, mps, redshiftCut – as findVoidsLightcone from sky positions
divergenceCellSize – the cell size in units of mps; finite and positive. A reasonable starting value is min(1, (20 / R)^(1/3)), R the number of realizations the search will read.
- Throws:
Error – on every case of the entry of findVoidsLightcone that does not concern displacements, ids or the configuration, and of the grid’s construction
- Returns:
the grid, with geometry lightcone
Grid and watershed, box¶
-
DivergenceGrid bitvf::boxGrid(const otswap::BoxLimits &box, double mps, double divergenceCellSize)¶
The grid findVoidsBox builds on box limits, with this mps and cell size, bit for bit.
Only the fields that define the cells are set: geometry, lower, upper, nCellsAxis, nCells, cellSize, cellSizeMps and mps. limits, nRealizations, nRealizationsMean and every per-cell field are left empty or 0: records of a search, which a reuse ignores. The grid passes the checks of a grid to reuse, so that several searches can share it.
- Parameters:
box – the box limits the grid is built on, as the limits of findVoidsBox; each bound finite, with lower[k] < upper[k].
mps – mean particle separation, in coordinate units; finite and positive.
divergenceCellSize – the cell side in units of mps, as Config::divergenceCellSize; finite and positive.
- Throws:
Error – if a bound of box is not finite or a lower bound is not below the upper one; if mps or divergenceCellSize is not finite and positive; if the grid would hold more cells than an int64 index can address.
- Returns:
the grid, with only the fields that define the cells set.
-
DivergenceGrid bitvf::boxGrid(const otswap::Result &reconstruction, std::optional<double> divergenceCellSize = std::nullopt)¶
The grid findVoidsBox builds from this reconstruction, bit for bit: on otswap::Result::box, with otswap::Result::mps.
As the overload above. Without divergenceCellSize, the cell side is the default for the reconstruction’s realizations, min(1, (20 / nRealizations)^(1/3)) mps.
- Parameters:
reconstruction – a box result of otswap::reconstructBox, or the mean of one: the Result read from a mean displacement file by otswap::io::readDisplacementMean (nRealizations 1, nRealizationsMean the number averaged; set Config::nRealizationsMean to it, so that bitvf’s files record it). The box is the file’s box keywords, with or without BOXLIM; a mean file without box keywords holds no box limits and is refused. The divergence is not linear in the displacement, so a search on the mean of R realizations does not give the result of the search on the R realizations.
divergenceCellSize – the cell side in units of mps, as Config::divergenceCellSize; finite and positive. Empty for the default.
- Throws:
Error – if the reconstruction is not a box result (use lightconeGrid); if its nRealizations is 0; if its box is missing, has a bound not finite or a lower bound above the upper one, or differs from selection.boxLimits when those are set; if its mps is not finite and positive; if divergenceCellSize is set and not finite and positive; if the grid would hold more cells than an int64 index can address.
- Returns:
the grid, with only the fields that define the cells set.
-
Partition bitvf::watershedBox(const std::vector<double> &field, const std::array<std::size_t, 3> &nCellsAxis, otswap::Verbosity verbosity = otswap::Verbosity::Normal, std::ostream *log = &std::clog)¶
Split a field on a box grid into basins by steepest descent.
The descent is that of the void finder (BasinCatalog): each cell flows to the neighbour, among the 26 cut at the faces of the grid, where the field drops the most, ties to the lowest row; a cell with no strictly smaller neighbour is a seed. Seeds below 0 start voids, seeds at or above 0 overdense basins; each kind is numbered by ascending seed row. A field with another convention, such as a density or a density contrast with voids above 0, must be shifted or flipped before the call. No smoothing, no fill and no centres: the field is used as given. A field with no cell below 0 gives no void, and no error. The result does not depend on the number of threads.
- Parameters:
field – the value of each cell, nx * ny * nz entries; cell (i, j, k) is row (i * ny + j) * nz + k.
nCellsAxis – the cells along x, y, z, (nx, ny, nz), each at least 1; they need not be equal.
verbosity, log – what the call reports and where, as Config::verbosity and Config::log: at Normal, one line with its time,
and at Detailed, before it, the cells in voids and in overdense basins, and how many of each lie in the cores.bitvf: watershedBox: <V> voids and <O> overdense basins on <nx> x <ny> x <nz> cells in <T> s
- Throws:
Error – if a count of nCellsAxis is 0; if field does not hold nx * ny * nz entries; if an entry of field is not finite.
- Returns:
the voids and overdense basins: the basin of each cell, the seed and the cells of each basin.
-
struct Partition¶
The basins of a field on a box grid, as watershedBox finds them, with no catalogue.
Public Members
-
std::size_t nVoids = 0¶
Number of voids.
-
std::size_t nOverdense = 0¶
Number of overdense basins.
-
std::vector<std::int64_t> voidIndex¶
[cell]: row of the cell’s void, -1 none.
-
std::vector<std::int64_t> overdenseIndex¶
[cell]: row of the cell’s overdense basin, -1 none.
-
std::vector<std::int64_t> voidSeed¶
[void]: row of its seed cell, ascending.
-
std::vector<std::int64_t> overdenseSeed¶
[overdense basin]: row of its seed cell, ascending.
-
std::vector<std::uint64_t> voidCells¶
[void]: cells of the extended void, and of its core (field below 0).
-
std::vector<std::uint64_t> overdenseCells¶
[overdense basin]: cells of the basin, and of its core (field at or above 0).
-
std::size_t nVoids = 0¶
bitvf/BitVF.h¶
Configuration¶
-
struct BoxConfig¶
The parameters of runBox.
Public Members
-
otswap::Config ot¶
The reconstruction, used for both reconstructions of a run with correction, with the same seed. A seed of 0 is replaced by one drawn from std::random_device before the first reconstruction, and both use it; otswap::Result::config records it.
-
std::optional<otswap::BoxLimits> limits¶
The box of the run, given to otswap::reconstructBox as limits on both reconstructions. Empty: the bounding box of the tracers, or of the tracers and the randoms when randoms are given. A point on a face is inside.
-
std::optional<double> mps¶
The mean particle separation, in coordinate units, given to both reconstructions. Empty: otswap computes it on each from the volume of the box and the tracers inside it (otswap::Result::mps).
-
std::optional<BoxRsd> rsd¶
The correction of redshift-space distortions. Empty: one reconstruction and one search, no correction.
-
Config voids¶
The void search, on every pass. Its verbosity and log also govern the lines of the pipeline itself (runBox).
-
bool keepReconstructions = false¶
Keep the otswap results and the corrected catalogue in BitVFResult.
-
otswap::Config ot¶
-
struct BoxRsd¶
Correction of redshift-space distortions in a box, as otswap::realSpaceBox applies it.
axis, redshift, bias and sigma have no default: each must be set.
Public Members
-
std::optional<unsigned> axis¶
The line of sight: 0, 1 or 2, for x, y or z. Empty is an error.
-
double redshift = std::numeric_limits<double>::quiet_NaN()¶
The redshift of the box, at which the growth rate f is read from the distance table; inside the table’s range.
-
double bias = std::numeric_limits<double>::quiet_NaN()¶
The linear bias of the tracers, constant; finite and positive.
-
double sigma = std::numeric_limits<double>::quiet_NaN()¶
Width of the neighbour average of the displacements, in coordinate units; 0 for none, finite and non-negative. For coordinates in Mpc/h, 10 Mpc/h is a reasonable starting value; the best value depends on the sample, and should be checked in each analysis.
-
otswap::CorrectionConfig correction¶
The weighting of the neighbour average, and what the correction reports; passed to otswap::realSpaceBox unchanged.
-
bool zspaceVoids = false¶
Also search voids on the first, redshift-space, reconstruction (BitVFResult::zspaceVoids).
-
std::optional<unsigned> axis¶
-
struct LightconeConfig¶
The parameters of runLightcone.
Public Members
-
otswap::Config ot¶
The reconstruction, used for both reconstructions of a run with correction, with the same seed. A seed of 0 is replaced by one drawn from std::random_device before the first reconstruction, and both use it; otswap::Result::config records it.
-
unsigned nBins = 0¶
The redshift bins of the mps(z) profile of each reconstruction (otswap::reconstructLightcone); at least 1. 30 is a reasonable starting value.
-
otswap::RedshiftCut cut¶
The closed range of observed redshift of the run, given to both reconstructions and to every search: the tracers outside keep their row and are skipped, the randoms outside are removed. The default cuts nothing.
-
std::optional<LightconeRsd> rsd¶
The correction of redshift-space distortions. Empty: one reconstruction and one search, no correction.
-
Config voids¶
The void search, on every pass. Its verbosity and log also govern the lines of the pipeline itself (runLightcone).
-
bool keepReconstructions = false¶
Keep the otswap results and the corrected catalogue in BitVFResult.
-
otswap::Config ot¶
-
struct LightconeRsd¶
Correction of redshift-space distortions in a lightcone, as otswap::realSpaceLightcone applies it.
bias and sigma have no default: each must be set.
Public Members
-
otswap::BiasTable bias¶
The linear bias of the tracers as a function of redshift; it must give a positive bias at the redshift of every tracer kept.
-
double sigma = std::numeric_limits<double>::quiet_NaN()¶
Width of the neighbour average of the displacements, in coordinate units; 0 for none, finite and non-negative. For coordinates in Mpc/h, 10 Mpc/h is a reasonable starting value; the best value depends on the sample, and should be checked in each analysis.
-
otswap::CorrectionConfig correction¶
The weighting of the neighbour average, and what the correction reports; passed to otswap::realSpaceLightcone unchanged.
-
SecondPassRandoms secondPassRandoms = SecondPassRandoms::Resample¶
The randoms of the second reconstruction. Resample, the default, gives them the redshift distribution of the corrected tracers; None keeps the observed one; External takes randoms built by the user for the real-space sample.
-
bool zspaceVoids = false¶
Also search voids on the first, redshift-space, reconstruction (BitVFResult::zspaceVoids).
-
otswap::BiasTable bias¶
-
enum class bitvf::SecondPassRandoms¶
The randoms of the second, real-space, reconstruction of a lightcone run (runLightcone).
Values:
-
enumerator None¶
the first reconstruction’s randoms, unchanged
-
enumerator Resample¶
the first reconstruction’s randoms, with redshifts drawn from the corrected tracers
-
enumerator External¶
randoms given to runLightcone for the second reconstruction
-
enumerator None¶
Pipeline, box¶
-
BitVFResult bitvf::runBox(const std::vector<double> &tracers, const std::vector<double> &randoms, const BoxConfig &config, const std::vector<std::int64_t> &ids = {})¶
Reconstruct a box and find its voids, without correction of redshift-space distortions.
The run:
Checks every argument and every field of config that can be checked before any work, so that an invalid run fails before the reconstruction.
Fixes the box: config.limits, or the bounding box of the tracers, or of the tracers and the randoms when randoms are given.
Without randoms, draws config.ot.nRealizations * N of them, uniformly in the box, N the tracers inside it (Result::randomSeed describes the draw).
Reconstructs with otswap::reconstructBox: the randoms, the box as limits, config.mps when given.
Searches with findVoidsBox on that reconstruction. The search reads otswap::Result::mps, so the reconstruction and the search use one mean particle separation.
The box always reaches otswap as limits, so Result::limits holds it, and the files record it, also when config.limits is empty. Its mean particle separation is then otswap’s without limits, bit for bit, unless the randoms given reach beyond the tracers, which enlarges the box and so the mps.
- Randoms drawn
The seed is s = config.ot.seed + 1299709, modulo 2^32, a seed of 0 counting as the one drawn to replace it (BoxConfig::ot); s is recorded in Result::randomSeed of every pass and written as the keyword RANDSEED of bitvf’s files. One std::mt19937 seeded with s draws, for each random in turn, x, y and z, each as lo + u (hi - lo) over the box’s range on that axis, with u = (a 2^26 + b) / 2^53, a the first output shifted right by 5 bits and b the second shifted right by 6; a value that rounds to hi or above is replaced by the largest double below hi, std::nextafter(hi, lo), with no further draw, so every random lies inside the box and the sequence of outputs is unchanged. s alone reproduces the randoms. They are given to otswap as given randoms; otswap’s displacement files record config.ot.seed in SEED.
- Identity
ids are the tracers’ identity: empty means the rows received. They go to otswap::Result::ids and Result::ids.
- Reports
Each step reports at its own configuration’s level: config.ot.verbosity for the reconstruction, config.voids.verbosity for the search (Config::verbosity). At config.voids.verbosity Detailed, runBox adds, after drawing the randoms:
and at Normal, last:bitvf: drew <n> randoms in <box> with seed <s> in <t> s
T the time of the whole call. Each line is written as soon as its step finishes, from the calling thread; a call that throws never writes the call line.bitvf: runBox: <V> voids and <O> overdense basins from <N> tracers in <T> s
- Parameters:
tracers – Cartesian coordinates, in coordinate units, 3 * N entries.
randoms – Cartesian coordinates of the randoms, or empty to have them drawn. Given, they must number at least config.ot.nRealizations
N inside the box; those outside it are dropped by otswap. They go to the reconstruction only: the box search takes no randoms.
config – the parameters; config.rsd must be empty (the correction needs a distance table: use the overload below).
ids – the tracers’ identity, or empty; one per tracer, no value twice.
- Throws:
Error – if an argument or a field of config is invalid, as findVoidsBox and otswap::reconstructBox require, if config.rsd is set, if the bounding box spans no volume or has an infinite width on an axis, if randoms are to be drawn and no tracer lies inside the box, from otswap (prefixed “otswap: “, the original nested), and from the search, as findVoidsBox.
- Returns:
the voids, and with config.keepReconstructions the reconstruction.
-
BitVFResult bitvf::runBox(const std::vector<double> &tracers, const std::vector<double> &randoms, const otswap::DistanceTable &distances, const BoxConfig &config, const std::vector<std::int64_t> &ids = {})¶
Reconstruct a box, correct its redshift-space distortions, reconstruct it again in real space and find its voids.
Without config.rsd, as the overload above, and distances is not read. With it, the first four steps above, then:
With BoxRsd::zspaceVoids, searches the first reconstruction (BitVFResult::zspaceVoids).
Builds the grid of the first reconstruction, boxGrid(first reconstruction, config.voids.divergenceCellSize): the grid of every search of the run, the one the redshift-space search builds.
Corrects the tracers with otswap::realSpaceBox (BoxRsd, distances).
Selects, in input order, the tracers corrected (status Corrected or MovedByNeighbours) whose corrected position lies in a cell of that grid. The others are excluded, with their row kept: those the correction left unmoved (NoValidNeighbour, and LeftOut, which includes the tracers outside the box) are flagged in Result::uncorrected, those moved outside every cell in Result::outsideGrid.
Reconstructs the selected tracers at their corrected positions, with the randoms of the first reconstruction (given or drawn), the same box as limits, config.mps when given, and the same seed. Their ids are the input’s ids of the rows selected, or the rows themselves when no ids were given.
Searches that reconstruction on the grid built above, with findVoidsBox’s grid argument: the same cells, and the smoothing and the delta2Mps radius from the first reconstruction’s mean particle separation, which is Result::mps. The second reconstruction’s own mps, recomputed by otswap from the fewer tracers when config.mps is empty, serves its reconstruction only. A tracer moved outside the box but into a cell is outside the box for the second reconstruction and is skipped by the search (TracerAssignment::inBox).
Returns the search with one row per input tracer.
- Rows of Result::voids
The selected rows carry the search’s values. An excluded row carries -1 in every index, NaN in TracerAssignment::distance, 0 in TracerAssignment::used, and the first reconstruction’s value in TracerAssignment::inBox (0 for a tracer outside BoxConfig::limits, 1 otherwise); and one flag, uncorrected before outsideGrid. A tracer outside the box of the first reconstruction is uncorrected (LeftOut), and uncorrected means only that the correction did not move it. Result::ids are the ids given, or empty when none. nTracers is N; Result::counts counts the input rows: tracers N; tracersUncorrected and tracersOutsideGrid the rows flagged; tracersOutsideBox the rows outside the limits in the first reconstruction plus those the second search found outside among the selected tracers; tracersUsed and displacements as the second search counted them among the selected tracers.
- Reports
As the overload above, the correction at BoxRsd::correction::verbosity, and at config.voids.verbosity Detailed, after the selection of the corrected tracers:
The second search’s own lines count the selected tracers.bitvf: second pass on <k> of <N> tracers: <u> uncorrected, <g> outside the first pass's grid in <t> s
- Parameters:
tracers – as above, in redshift space.
randoms – as above; the first reconstruction’s randoms are enough for the second, which has fewer tracers.
distances – a table carrying the growth rate at BoxRsd::redshift (otswap::rsdFactorBox).
config – as above.
ids – as above.
- Throws:
Error – as the overload above, but for config.rsd; if a field of config.rsd is invalid or the distance table cannot give the factor (otswap::rsdFactorBox), checked before the first reconstruction; if no tracer is selected for the second reconstruction; from otswap (prefixed “otswap: “, the original nested), and from each search, as findVoidsBox.
- Returns:
the voids, and as config asks the redshift-space voids, the two reconstructions and the corrected catalogue.
Pipeline, lightcone¶
-
BitVFResult bitvf::runLightcone(const std::vector<double> &tracersSky, const std::vector<double> &randomsSky, const otswap::Mask &mask, const otswap::DistanceTable &distances, const LightconeConfig &config, const std::vector<double> &randomsSkySecondPass = {}, const std::vector<std::int64_t> &ids = {})¶
Reconstruct a lightcone and find its voids, optionally correcting its redshift-space distortions and reconstructing it again in real space.
The run:
Checks every argument and every field of config that can be checked before any work, so that an invalid run fails before the reconstruction. With a correction, the factor of the correction is computed once at the observed redshifts of the tracers kept, so that a table without growth rate or an unusable bias fails here.
Reconstructs with otswap::reconstructLightcone: the randoms, the mask, config.nBins, the distance table, config.ot and config.cut. The tracers on unobserved pixels or outside the cut take no part.
Without config.rsd, searches that reconstruction with findVoidsLightcone (reconstruction, randomsSky, mask, config.voids) and returns.
With config.rsd, after the first reconstruction:
Builds the grid of the first reconstruction, with config.voids.divergenceCellSize: the grid of every search of the run, the one the redshift-space search would build.
With LightconeRsd::zspaceVoids, searches the first reconstruction on it (BitVFResult::zspaceVoids).
Corrects the tracers with otswap::realSpaceLightcone (LightconeRsd, distances). The correction moves a tracer in redshift only.
Selects, in input order, the tracers corrected (status Corrected or MovedByNeighbours) whose corrected redshift lies inside config.cut and whose corrected position lies in a cell of the grid. The others are excluded, with their row kept, and flagged: those the correction left unmoved (NoValidNeighbour, and LeftOut, which includes the tracers on unobserved pixels or outside the cut) in Result::uncorrected, those moved outside the cut in Result::outsideCut, those moved outside every cell in Result::outsideGrid.
Reconstructs the selected tracers at their corrected redshifts, with the randoms of LightconeRsd::secondPassRandoms (below), the same mask, cut, bins and seed. Their ids are the input’s ids of the rows selected, or the rows themselves when no ids were given.
Searches that reconstruction on the grid built above: the same cells, and the first reconstruction’s mps(z) profile for the smoothing and the densities. The second reconstruction’s own profile serves its reconstruction only.
Returns the search with one row per input tracer.
- Rows of Result::voids
The selected rows carry the search’s values. An excluded row carries -1 in every index, NaN in TracerAssignment::distance and 0 in TracerAssignment::used, and exactly one flag, uncorrected before outsideCut before outsideGrid. TracerAssignment::inMask and inCut are those of the first reconstruction for every row: a tracer on an unobserved pixel or outside the cut is uncorrected (LeftOut) as well, and uncorrected means only that the correction did not move it. Result::ids are the ids given, or empty when none. nTracers is N; Result::counts counts the input rows: tracers N; tracersUncorrected, tracersOutsideCut and tracersOutsideGrid the rows flagged; tracersOutsideMask and tracersOutsideRedshiftCut those of the first reconstruction; tracersUsed, tracersInMaskedCells, displacements, displacementsRejected and the counts of the randoms as the second search counted them.
- Second-pass randoms
None: the randoms given, unchanged; both reconstructions remove the same ones by the mask and the cut.
Resample: one random for each of the K randoms given that lie on observed pixels inside the cut, in row order, with the same right ascension and declination, bit for bit. Their redshifts are drawn from the k tracers selected after the correction: the seed is s = config.ot.seed + 104729, modulo 2^32, a seed of 0 counting as the one drawn to replace it; one std::mt19937 seeded with s gives, for each random in turn, otswap::uniformInt(engine, k) (Lemire’s multiply-and-reject), and the random takes the corrected redshift of the selected tracer of that index, counted in row order. The draw is serial and takes nothing else from the engine, so s alone reproduces the redshifts. s is recorded in Result::randomSeed of BitVFResult::voids only. The search removes and counts the randoms that fall outside the grid.
External:
randomsSkySecondPass, checked before the first reconstruction asrandomsSkyis (those on unobserved pixels or outside the cut are not read further). After the selection, those outside the grid are removed from the array the second reconstruction takes; the search takes the whole array and removes and counts them itself. At least config.ot.nRealizations times the k tracers selected must remain.
- Identity
ids are the tracers’ identity: empty means the rows received. They go to otswap::Result::ids and Result::ids.
- Reports
Each step reports at its own configuration’s level: config.ot.verbosity for the reconstructions, LightconeRsd::correction::verbosity for the correction, config.voids.verbosity for the searches (Config::verbosity). At config.voids.verbosity Detailed, runLightcone adds, after the selection of the corrected tracers:
followed, with None, bybitvf: second pass on <k> of <N> tracers: <u> uncorrected, <c> outside the redshift cut, <g> outside the first pass's grid in <t> s
K the randoms on observed pixels inside the cut, or, with Resample, bybitvf: second-pass randoms: the first pass's <K>
With External, at Normal, in place of that line:bitvf: resampled the redshifts of <K> randoms from <k> tracers with seed <s>
and at Normal, last:bitvf: external randoms: <E> given, <m> on unobserved pixels, <c> outside the redshift cut, <g> outside the first pass's grid, <K> kept of <n> needed
T the time of the whole call. Each line is written as soon as its step finishes, from the calling thread; a call that throws never writes the call line. The second search’s own lines count the selected tracers.bitvf: runLightcone: <V> voids and <O> overdense basins from <N> tracers in <T> s
- Parameters:
tracersSky – sky positions of the tracers, [tracer][ra, dec, z], radians, z the observed redshift, as findVoidsLightcone takes them.
randomsSky – sky positions of the randoms, as tracersSky; required. They describe the survey: every systematic belongs in them. The reconstruction needs at least config.ot.nRealizations times the tracers kept on observed pixels inside the cut.
mask – the observed pixels of the survey, given to both reconstructions and to every search.
distances – the redshift-distance table, carrying the growth rate when config.rsd is set.
config – the parameters.
randomsSkySecondPass – the randoms of the second reconstruction with SecondPassRandoms::External, as randomsSky; empty otherwise.
ids – the tracers’ identity, or empty; one per tracer, no value twice.
- Throws:
Error –
before the first reconstruction: on tracersSky, randomsSky, ids and config.cut as findVoidsLightcone; if no random is left on observed pixels inside the cut; if config.nBins or config.ot.nRealizations is 0; on config.voids as findVoidsLightcone; if randomsSkySecondPass is given without a correction or with None or Resample, or is empty with External; if LightconeRsd::sigma is not finite and non-negative; with External, if randomsSkySecondPass is malformed, has a kept row with a redshift outside the distance table, or keeps no row; if the factor of the correction cannot be computed (the table has no growth rate, the bias is not positive), from otswap;
during the run: from otswap (prefixed “otswap: “, the original nested), a corrected distance outside the table included; from each search and from the grid of the run, as findVoidsLightcone; if no tracer is selected, giving the three counts; with External, if fewer randoms remain than needed, giving the counts.
- Returns:
the voids, and as config asks the redshift-space voids, the reconstructions and the corrected catalogue.
-
struct BitVFResult¶
Output of runBox and runLightcone.
Given the same inputs and a seed other than 0, every field but the elapsedSeconds of the searches, of the kept otswap results and of the kept catalogue is the same bit for bit whatever the number of threads.
Public Members
-
Result voids¶
The voids of the run: of the real-space pass with a correction, of the only pass without. Its per-tracer columns have one row per input tracer, in input order.
-
std::optional<Result> zspaceVoids¶
The voids of the redshift-space pass, when BoxRsd::zspaceVoids or LightconeRsd::zspaceVoids is set: the search of zspaceReconstruction (findVoidsBox, findVoidsLightcone).
-
std::optional<otswap::Result> reconstruction¶
With keepReconstructions: the reconstruction the voids were found on. With a correction its rows are the second reconstruction’s tracers only (runBox, runLightcone), and its ids are their identity among the input’s.
-
std::optional<otswap::Result> zspaceReconstruction¶
With keepReconstructions and a correction: the first, redshift-space, reconstruction, one row per input tracer.
-
std::optional<otswap::RealSpaceCatalog> realSpace¶
With keepReconstructions and a correction: the corrected catalogue, one row per input tracer.
-
Result voids¶
bitvf/io.h¶
The columns and keywords of each file are on the Lightcone file formats and Box file formats pages.
Writers¶
-
enum class bitvf::io::Product¶
The products, each with its file-name stem: voids, overdense_basins, divergence, galaxies.
Values:
-
enumerator Voids¶
-
enumerator Overdense¶
-
enumerator Divergence¶
-
enumerator Galaxies¶
-
enumerator Voids¶
-
std::string bitvf::io::fileName(Product product, const std::string &directory, const std::string &name, bool zspace)¶
The conventional name of the file of a product.
<directory>/<stem>_[zspace_]<name>, with the stem of the product. A ‘/’ is added only when directory is not empty and does not end in one; an empty directory gives<stem>_[zspace_]<name>. The extension, which sets the format, is part of name.- Parameters:
product – the product, which sets the stem.
directory – the folder of the file; empty for none.
name – the end of the file name, with the extension that sets the format.
zspace – true only for the redshift-space pass of a run with redshift-space correction, whose files then do not collide with those of the real-space pass.
- Throws:
Error – if name is empty.
- Returns:
the path of the file.
-
void bitvf::io::writeVoids(const std::string &file, const Result &result)¶
Write the voids, one row per void (Result::voids).
Columns: index (K); in a lightcone centreRA and centreDec, in degrees, and centreRed; centreX, centreY, centreZ, in coordinate units; radius, radiusExt, in coordinate units; deltaAv; delta2Mps; edgeFlag (J; 0 none, 1 extended basin only, 2 core); contamination; nTracers (K). A field result has no deltaAv, delta2Mps and nTracers, and has fieldCentre after contamination. Keywords as listed in the file description, the row count NBASINS. ASCII: 9 significant digits.
- Parameters:
file – the file to write; its extension sets the format.
result – the result of a box or lightcone search.
- Throws:
Error –
if it is malformed, the message starting with “writeVoids: “: Config::divergenceCellSize empty (in a field result, only when Result::mps is a number), Config::nRealizationsMean 0, a column of the catalogue not of nBasins entries (centre 3 * nBasins; centreSky 3 * nBasins in a lightcone, empty in a box), in a lightcone maskNside outside [1, 536870912], a column of the other kind of result not empty (fieldCentre, or deltaAv, delta2Mps and nTracers in a field result), a count above the largest 64-bit integer;
if the file cannot be written: the message starts with “otswap: “, the otswap::Error nested.
-
void bitvf::io::writeOverdense(const std::string &file, const Result &result)¶
Write the overdense basins, one row per basin (Result::overdense), with the columns, keywords and errors of writeVoids.
- Parameters:
file – the file to write, as writeVoids.
result – the result of a box or lightcone search.
-
void bitvf::io::writeDivergence(const std::string &file, const Result &result)¶
Write the divergence grid, one row per cell (Result::divergence).
Columns: index (K); cellX, cellY, cellZ, the cell centre, in coordinate units; in a lightcone cellRA, cellDec (degrees), cellRed, cellDist (the distance of the centre), cellRAMin, cellRAMax, cellDecMin, cellDecMax (degrees), cellDistMin, cellDistMax, which describe the cells, are taken from the grid rebuilt from its record and are not read back as the grid; divergence, before smoothing; divergenceSmoothed, only when DivergenceGrid::divergenceSmoothed is not empty; volume, in coordinate units cubed; weight; weightSmoothed, only when DivergenceGrid::weightSmoothed is not empty; nDispl (K), the displacement ends counted; nTracers (K); voidIndex (K); overdenseIndex (K); in a lightcone masked (J), 1 on an unobserved pixel. A field result has no nDispl and nTracers. ASCII: 17 significant digits.
Keywords as listed in the file description, the row count NCELLS, followed by the record of the grid: LOWERX, LOWERY, LOWERZ, UPPERX, UPPERY, UPPERZ, CELLSIDE, in coordinate units, and NCELLX, NCELLY, NCELLZ. With MPS and CELLSIZE, they hold every field that defines the cells at 17 significant digits, so the grid read back is the same bit for bit.
A lightcone file has, after the common keywords, the record of the grid: DISTMIN, DISTMAX, in coordinate units, and RAMIN, RAMAX, DECMIN, DECMAX, in degrees, with CELLSIZE (the angles read back equal to the rounding of the conversion). The mps(z) profile follows in a second table, HDU MPSPROF in FITS and the twin file <stem>.mps.<ext> in ASCII (otswap::io::twinFile), with columns redshift, MPS and nTracers (J), 17 digits, and keywords PRODUCT (divergence mps profile), BITVFV, ZMIN, ZMAX and MPSREPR. It holds no GEOMETRY. The grid is written only if it passes the checks of a grid to reuse and is rebuilt from its record and Result::distances with the same number of cells, and if it agrees with the result, so that every file written reads back as a grid to reuse; this costs one grid build.
- Parameters:
file – the file to write, as writeVoids.
result – the result of a box or lightcone search, with its divergence grid.
- Throws:
Error –
if the result holds no divergence grid (Config::keepDivergence);
lightcone: if the result holds no distance table or no mps profile, or its maskNside is outside [1, 536870912], the message starting with “writeDivergence: the result is malformed: “; if the grid fails the checks of a grid to reuse (see findVoidsLightcone), the message starting with “writeDivergence: the divergence grid …”; if its rebuild from the record fails, the builder’s message after “writeDivergence: “, naming the divergence grid, or gives another number of cells; if a column of the grid is not of nCells entries (centre and centreSky 3 * nCells; divergenceSmoothed, weightSmoothed and the limits of the cells nCells or none); if its mps profile, cellSizeMps, nRealizations or nRealizationsMean differ from Result::mpsProfile, Config::divergenceCellSize, Result::nRealizations or Config::nRealizationsMean, bit for bit;
box: if the grid fails the checks of a grid to reuse (see findVoidsBox), the message starting with “writeDivergence: cannot write the
divergence: “; in a field result, which no search reuses, only if its cell side is not finite and positive, a bound of lower or upper is not finite, or nCells is not the product of nCellsAxis;
box: if it is malformed, the message starting with “writeDivergence: “, as writeVoids; a column of the grid not of nCells entries (centre 3 * nCells; divergenceSmoothed and weightSmoothed nCells or none); outside a field result, the mps, cellSizeMps or limits of the grid different from Result::mps, Config::divergenceCellSize or Result::limits, bit for bit; its nRealizations or nRealizationsMean different from Result::nRealizations or Config::nRealizationsMean;
if the file cannot be written, as writeVoids.
-
void bitvf::io::writeGalaxies(const std::string &file, const Result &result)¶
Write where each tracer ended up, one row per input tracer, in input order (Result::assignment).
Columns: id (K), Result::ids, or the row from 0 when it is empty; cellIndex (K); voidIndex (K); overdenseIndex (K); distance, from the centre of the tracer’s basin, in coordinate units, NaN for a tracer not in a basin; inMask (J), only when TracerAssignment::inMask is not empty (a lightcone); inCut (J), only in a lightcone with a bounded Result::redshiftCut; inBox (J), only when Result::limits is set; used (J), only when TracerAssignment::used is not empty (it is empty after findVoidsBoxFromDivergence); uncorrected (J), only when Result::uncorrected is not empty; outsideGrid (J), only when Result::outsideGrid is not empty; outsideCut (J), only when Result::outsideCut is not empty. Keywords as listed in the file description, the row count NOBJECTS. ASCII: 9 significant digits.
- Parameters:
file – the file to write, as writeVoids.
result – the result of a box or lightcone search on tracers, with its tracer assignment.
- Throws:
Error –
if the result is a field result, or holds no tracer assignment (Config::keepAssignment);
if it is malformed, the message starting with “writeGalaxies: “: Config::divergenceCellSize empty, Config::nRealizationsMean 0; ids, uncorrected, outsideGrid or outsideCut neither empty nor of nTracers entries; a column of the assignment not of nTracers entries (inMask, and inCut with a bounded cut, in a lightcone; inBox in a box; the others empty);
if the file cannot be written, as writeVoids.
Readers¶
-
DivergenceGrid bitvf::io::readDivergence(const std::string &file)¶
Read a divergence file written by writeDivergence.
Every field the writer wrote is read back bit for bit, in both formats: the cells (lower, upper, cellSize, nCellsAxis, nCells, mps, cellSizeMps), the box limits, nRealizations, nRealizationsMean and every per-cell column, divergenceSmoothed and weightSmoothed when the file has them. The grid passes the checks of a grid to reuse, so it can be passed to findVoidsBox as grid; the per-search fields are records, which a search reusing the grid does not read.
A lightcone file gives a lightcone grid: the record (distances and cellSizeMps bit for bit, the angles within the rounding of their conversion from degrees, so a tracer within rounding of a cell edge can change cell; a right-ascension range of at most 360 degrees is kept within 2 pi), the mps profile from its part, the cell centres, their sky positions, the fields, the counts, the basin indices and masked. The limits of the cells (cellRaMin … cellDistanceMax) are not read; writeDivergence rebuilds them. It passes the checks of a grid to reuse, so it can be passed to findVoidsLightcone as grid.
The divergence file of a field result has no NREC and is refused; read it with readField.
- Parameters:
file – the file, FITS or ASCII by its extension.
- Throws:
Error –
if the file cannot be read, or lacks a column, or an integer column holds anything but an integer: the message starts with “otswap: “, the otswap::Error nested;
if it has no PRODUCT keyword, its PRODUCT is not divergence, or GEOMETRY is not box or lightcone; if a keyword of the other geometry is present (the box’s MPS, CELLSIDE, LOWER*, UPPER*, NCELL*, BOXLIM, BOX*; the lightcone’s DISTMIN, DISTMAX, RAMIN, RAMAX, DECMIN, DECMAX);
lightcone: if the profile part is missing, “the mps profile part is
missing”, or its PRODUCT is not divergence mps profile;
if a keyword of the grid record is missing, not a number, or not a whole number in range; if NREC or NRECMEAN is 0; if BOXLIM holds anything but 1, or BOXLIM and the six box keywords do not come together;
if the rows are not NCELLS, index is not 0 to NCELLS - 1 in order, a count is negative, a basin index is below -1, or (lightcone) masked is not 0 or 1: the message names the data row, counted from 1 among the data rows (comment and blank lines do not count), as “data row k (from 1)”;
if the grid fails the checks of a grid to reuse (lightcone: of the record and the profile only, there being no distance table).
- Returns:
the grid, with every field the file holds.
-
Field bitvf::io::readField(const std::string &file, const std::array<std::string, 3> ¢reColumns, const std::string &valueColumn, const std::string &weightColumn = "", char delimiter = ' ', char comment = '#')¶
Read a field at cell centres from a table, for findVoidsBoxFromField, in the order of the rows.
The columns are read through otswap::io::read: in FITS by name, from the table of HDU 2; in ASCII by name, from the last line starting with “###” before the data, or by 0-based index given as digits alone. Every value read must be finite; findVoidsBoxFromField checks the rest. A divergence file of bitvf is valid input:
const bitvf::io::Field f = bitvf::io::readField("divergence.fits", {"cellX", "cellY", "cellZ"}, "divergence", "weight");
- Parameters:
file – the table, FITS or ASCII by its extension.
centreColumns – the columns of x, y and z of the centres.
valueColumn – the column of the field.
weightColumn – the column of the weights, or empty for none.
delimiter – the separator of the columns of an ASCII file, as otswap::io::read; ignored for FITS.
comment – the character that starts a comment line of an ASCII file, as otswap::io::read; ignored for FITS.
- Throws:
Error – if the file cannot be read, a column is missing or named twice: the message starts with “otswap: “, the otswap::Error nested; if a value read is not finite: the message names the file, the data row, counted from 1 among the data rows (comment and blank lines do not count), as “data row k (from 1)”, and the column as selected.
- Returns:
the centres, the values and the weights, one per row in the order of the rows; the weights empty without weightColumn.
-
struct Field¶
A field at the centres of cells, for findVoidsBoxFromField.