Skip to content

Random numbers

ocelot.util.random.points_on_sphere(shape, radians=True, phi_symmetric=True, seed=None) ¤

Draws random points on the surface of a unit sphere.

Parameters:

Name Type Description Default
shape int

required number of deviates. Should be acceptable by np.random.rand().

required
radians bool

whether or not to return in radians. Default: True

True
phi_symmetric bool

whether or not to return a distribution for phi symmetric about zero (so, phi ~ [-pi/2, pi/2]) or whether to return one defined in the mathsy (but less useful for astronomy) way phi ~ [0, pi]. Default: True, i.e. phi is immediately usable as galactic latitude b or declination.

True
seed optional

Seed for the numpy random generator. Default: None

None

Returns:

Type Description
ndarray

theta values.

ndarray

phi values.

Notes

To draw random points on a sphere, you cannot simply use uniform deviates based on theta and phi! For a good explanation, see: http://mathworld.wolfram.com/SpherePointPicking.html

ocelot.util.random.unit_vectors(size, seed=None) ¤

Returns an array of random unit vectors on the surface of a 3D unit sphere.

Parameters:

Name Type Description Default
size int

Number of unit vectors to return.

required
seed optional

Seed for the numpy random generator. Default: None

None

Returns:

Type Description
ndarray

An array of shape (size, 3) of unit vectors.

Notes

To draw random points on a sphere, you cannot simply use uniform deviates based on theta and phi! For a good explanation, see: http://mathworld.wolfram.com/SpherePointPicking.html

ocelot.util.random.fractal_noise_2d(resolution, seed=None) ¤

Creates 2d fractal (pink) noise.

Implemented for use in making synthetic (correlated) differential reddening.

This function is completely beyond me. Thanks, StackOverflow! https://stackoverflow.com/a/76605642

Parameters:

Name Type Description Default
resolution int

Resolution of the noise.

required
seed optional

Seed for the numpy random generator. Default: None

None

Returns:

Type Description
ndarray

Array of shape (resolution, resolution) containing fractal noise.