Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split positions_from_delta() into individual functions #413

Open
ntessore opened this issue Nov 11, 2024 · 0 comments
Open

Split positions_from_delta() into individual functions #413

ntessore opened this issue Nov 11, 2024 · 0 comments
Assignees
Labels
api An (incompatible) API change science Science improvement or question

Comments

@ntessore
Copy link
Collaborator

ntessore commented Nov 11, 2024

Add your issue here

The current positions_from_delta() function carries out a large number of steps:

  • Apply bias model to given delta map.
  • Convert biased delta to mean number count in each map pixel.
  • Apply a visibility map.
  • Compute observed number counts from a distribution (e.g., Poisson).
  • Accumulate the galaxies in the number count map into batches of a given size (e.g., 1_000_000)
  • Sample random positions for each galaxy within its pixel.

This structure is very rigid, and makes it difficult to implement things such as #136.

We should split this up into individual functions, so that they can be mixed and matched with different implementations:

for i, delta in enumerate(matter):
    # mean number count in each pixel
    nbar = glass.nbar_from_density(arcmin2=ngal[i], nside=nside)
    # galaxy density from linear bias model, could be a complicated model
    gal = nbar * (1 + beff[i] * delta)
    # apply visibility map for this shell, could be a complicated model
    gal *= vmap[i]
    # Poisson-sample galaxy indices from map in batches
    for ipix in glass.batched_poisson(gal, rng=rng):
        # randomly sample galaxy positions within each pixel
        lon, lat = glass.random_healpix_positions(nside, ipix)

This needs a bit of experimentation for multi-dimensional arrays, but in principle seems feasible.

@ntessore ntessore added api An (incompatible) API change science Science improvement or question labels Nov 11, 2024
@ntessore ntessore self-assigned this Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api An (incompatible) API change science Science improvement or question
Projects
None yet
Development

No branches or pull requests

1 participant