glass-dev / glass

Generator for Large Scale Structure
https://glass.readthedocs.io
MIT License
31 stars 8 forks source link

Dealing with galaxy populations from leading axes #77

Closed ntessore closed 1 year ago

ntessore commented 1 year ago

The galaxy functions such as glass.galaxies.redshifts_from_nz() accept multi-dimensional array input where leading axes correspond to different galaxy populations.

However, the random point functions such as glass.points.positions_from_delta() only accepts a single dimension.

This currently leads to a slightly awkward conversion, where one has to sum the number density of each galaxy population before passing it to the points sampler:

ngal = np.sum(np.trapz(dndz, z))

I want to propose a change where the functions in glass.points also work on multi-dimensional inputs. For example, glass.points.positions_from_delta() could accept

If inputs are given with array shape, the output arrays lon, lat would then be lists of the sampled points. Internally, the splitting can be handled by np.split(). Additionally, there could be support for a flat=True keyword argument that returns flat 1-D arrays of lon, lat and a 1-D array of population sizes, i.e. the inputs to np.split().