Random points¶
The following functions provide functionality for simulating point processes on the sphere and sampling random positions.
Sampling¶
- glass.positions_from_delta(ngal, delta, bias=None, vis=None, *, bias_model='linear', remove_monopole=False, batch=1000000, rng=None)[source]¶
Generate positions tracing a density contrast.
The map of expected number counts is constructed from the number density, density contrast, an optional bias model, and an optional visibility map.
If
remove_monopole
is set, the monopole of the computed density contrast is removed. Over the full sky, the mean number density of the map will then match the given number density exactly. This, however, means that an effectively different bias model is being used, unless the monopole is already zero in the first place.The function supports multi-dimensional input for the
ngal
,delta
,bias
, andvis
parameters. Extra dimensions are broadcast to a common shape, and treated as separate populations of points. These are then sampled independently, and the results concatenated into a flat list of longitudes and latitudes. The number of points per population is returned incount
as an array in the shape of the extra dimensions.- Parameters:
ngal (
float
|ndarray
[Any
,dtype
[float64
]]) – Number density, expected number of points per arcmin2.delta (
ndarray
[Any
,dtype
[float64
]]) – Map of the input density contrast. This is fed into the bias model to produce the density contrast for sampling.bias (
float
|ndarray
[Any
,dtype
[float64
]] |None
) – Bias parameter, is passed as an argument to the bias model.vis (
ndarray
[Any
,dtype
[float64
]] |None
) – Visibility map for the observed points. This is multiplied with the full sky number count map, and must hence be of compatible shape.bias_model (
str
|Callable
[...
,Any
]) – The bias model to apply. If a string, refers to a function in thepoints
module, e.g.'linear'
forlinear_bias()
or'loglinear'
forloglinear_bias()
.remove_monopole (
bool
) – If true, the monopole of the density contrast after biasing is fixed to zero.batch (
int
) – Maximum number of positions to yield in one batch.rng (
Generator
|None
) – Random number generator. If not given, a default RNG is used.
- Yields:
lon – Columns of longitudes for the sampled points.
lat – Columns of latitudes for the sampled points.
count – The number of sampled points If multiple populations are sampled, an array of counts in the shape of the extra dimensions is returned.
- Raises:
TypeError – If the bias model is not a string or callable.
- Return type:
Generator
[tuple
[ndarray
[Any
,dtype
[float64
]],ndarray
[Any
,dtype
[float64
]],int
|ndarray
[Any
,dtype
[int64
]]]]
- glass.uniform_positions(ngal, *, rng=None)[source]¶
Generate positions uniformly over the sphere.
The function supports array input for the
ngal
parameter.- Parameters:
- Yields:
lon – Columns of longitudes for the sampled points.
lat – Columns of latitudes for the sampled points.
count – The number of sampled points. For array inputs, an array of counts with the same shape is returned.
- Return type:
Generator
[tuple
[ndarray
[Any
,dtype
[float64
]],ndarray
[Any
,dtype
[float64
]],int
|ndarray
[Any
,dtype
[int64
]]]]
- glass.position_weights(densities, bias=None)[source]¶
Compute relative weights for angular clustering.
Takes an array densities of densities in arbitrary units and returns the relative weight of each shell. If bias is given, a linear bias is applied to each shell.
This is the equivalent of computing the product of normalised redshift distribution and bias factor \(n(z) \, b(z)\) for the discretised shells.
- Parameters:
- Returns:
The relative weight of each shell for angular clustering.
- Return type:
Bias¶
- glass.effective_bias(z, bz, w)[source]¶
Effective bias parameter from a redshift-dependent bias function.
This function takes a redshift-dependent bias function \(b(z)\) and computes an effective bias parameter \(\bar{b}\) for a given window function \(w(z)\).
- Parameters:
- Returns:
The effective bias parameter for the window.
- Return type:
Notes
The effective bias parameter \(\bar{b}\) is computed using the window function \(w(z)\) as the weighted average
\[\bar{b} = \frac{\int b(z) \, w(z) \, dz}{\int w(z) \, dz} \;.\]