yaw.randoms.HealPixRandoms#
- class yaw.randoms.HealPixRandoms(pix_values: NDArray, *, nested: bool = False, is_mask: bool = False, weights=None, redshifts=None, seed=12345)[source]#
Bases:
RandomsBaseGenerates random points within a HealPix mask.
The input mask can either be interpreted as a boolean mask or a probability map that indicates the probability at which random points should be generated in a given pixel. Requires installing
healpy.Call instance to generate random points.
Caution
To improve performance, this method does not create continuous random points, but randomly draws pixel center coordinates from the highest possible mask resolution supported by HealPix. This corresponds to a resolution of about \(2500\) pixels/arcsec.
- Parameters:
pix_values – Array with HealPix mask values.
nested – Whether the input mask is in the nested format.
is_mask – Whether the input mask should be interpreted as binary mask or as probability map (default).
weights – Optional array of weights to draw from.
redshifts – Optional array of redshifts to draw from.
seed – Integer number from which the random seed is generated.
- weights#
Optional array of weights to draw from.
- redshifts#
Optional array of redshifts to draw from.
- nside#
The HealPix
nsidevalue of the input mask.
- Raises:
ImportError – If
healpyis not installed.
Methods
__init__(pix_values, *[, nested, is_mask, ...])copy_chunk_info(*[, drop_patch_ids])Copy the data attribute information.
generate_dataframe(probe_size, *[, degrees])Draw a new sample of uniform random points into a pandas DataFrame.
Get the number attached data samples to draw from.
reseed([seed])Attributes
Whether this data source provides patch IDs.
Whether this data source provides redshifts.
Whether this data source provides weights.
- __call__(probe_size: int) TypeDataChunk#
Draw a new sample of uniform random points.
- Parameters:
probe_size – Number of points to generate.
- Returns:
Dictionary of arrays, always contains keys
raanddecfor coordinates of random points in radian. Optionally containsweightsand/orredshiftsif data as been provided to sample from.
- copy_chunk_info(*, drop_patch_ids: bool = False) DataChunkInfo#
Copy the data attribute information.
- generate_dataframe(probe_size: int, *, degrees: bool = True)#
Draw a new sample of uniform random points into a pandas DataFrame.
Requires installing the optional dependency pandas.
- Parameters:
probe_size – Number of points to generate.
- Keyword Arguments:
degrees – Whether to return the coordinates in degrees (the default).
- Returns:
A pandas.DataFrame, always contains keys
raanddecfor coordinates of random points in degrees or radian. Optionally containsweightsand/orredshiftsif data as been provided to sample from.
- get_data_size() int#
Get the number attached data samples to draw from.
Checks the length of the
weightsandredshiftsand returns their length. If neither are defined, returns -1.- Returns:
Number of observations or -1.
- Raises:
ValueError – If the lengths of the arrays do not match.
- property has_patch_ids: bool#
Whether this data source provides patch IDs.
- property has_redshifts: bool#
Whether this data source provides redshifts.
- property has_weights: bool#
Whether this data source provides weights.