API(fields): support for generating biased tracer fields #138
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR splits the interface for generating fields up so that it becomes possible to simulate multiple related fields, such as e.g. biased tracers.
The fundamental sampling of the Gaussian random field is done by the new
generate_alms()
generator, which returns the Gaussian alm for each shell. New functionsalm_to_gaussian()
andalm_to_lognormal()
can transform these alm to the respective random fields. The mean and variance of the Gaussian random field are stored inalm.dtype.metadata
, which helps in transforming the lognormal field without additional inputs being provided. The existinggenerate_gaussian()
andgenerate_lognormal()
are reimplemented in terms of the new functions.For generating biased tracers specifically, there is a new function
biased_cls()
which will take cls and apply linear bias factors. For lognormal fields, these biased cls can be transformed to biased Gaussian gls withlognormal_gls()
as usual. The newrescaled_alm()
function can then be used to change the power spectrum of a sampled Gaussian alm from the unbiased to the biased gls.Closes: #134
Closes: #131
Changed: The
gaussian_gls()
functions is now calleddiscretized_cls()
to better reflect its functionality.Changed: The
lognormal_gls()
function no longer callsdiscretized_cls()
/gaussian_gls()
internally.Added: A new
generate_alms()
generator for Gaussian alm.Added: New functions
alm_to_gaussian()
andalm_to_lognormal()
to transform Gaussian alm to the respective random fields.Added: A new
biased_cls()
function to apply bias factors to a sequence of cls.Added: A new
rescaled_alm()
function to change the power spectrum of a given alm array.