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

Allow Separable Growth Functions to compute Isotropized Power Spectra #1216

Merged
merged 4 commits into from
Dec 4, 2024

Conversation

paulrogozenski
Copy link
Contributor

A large bottleneck in the computation time of covariances is the calculation of isotropized power spectra. The current implementation calculates this at each scale factor considered in the computation. By separating the growth factor from this computation, one can save computation time and maintain accuracy to a good approximation.

The implementation includes optional flags when calculating the 2h_22, 3h, and 4h Trispectrum terms in pk_4pt.py and the corresponding functions for wrappers.

@coveralls
Copy link

coveralls commented Dec 3, 2024

Pull Request Test Coverage Report for Build 12161562031

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 17 of 17 (100.0%) changed or added relevant lines in 1 file are covered.
  • 36 unchanged lines in 7 files lost coverage.
  • Overall coverage increased (+0.04%) to 97.455%

Files with Coverage Reduction New Missed Lines %
pyccl/baryons/baccoemu_baryons.py 1 98.72%
pyccl/cells.py 1 97.92%
pyccl/nl_pt/ept.py 1 99.63%
pyccl/_nonlimber_FKEM.py 2 96.12%
pyccl/pk2d.py 3 98.71%
pyccl/tracers.py 12 95.07%
pyccl/halos/pk_4pt.py 16 96.25%
Totals Coverage Status
Change from base Build 11958349869: 0.04%
Covered Lines: 6548
Relevant Lines: 6719

💛 - Coveralls

@@ -669,6 +670,9 @@ def halomod_trispectrum_2h_22(cosmo, hmc, k, a, prof, *, prof2=None,
p_of_k_a (:class:`~pyccl.pk2d.Pk2D`): a `Pk2D` object to
be used as the linear matter power spectrum. If `None`, the power
spectrum stored within `cosmo` will be used.
separable_growth (Boolean): Indeicates whether a separable
Copy link

@rreischke rreischke Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: Indeicates -> Indicates and in all following occurrences.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and Boolean -> bool for consistency (and so the docs look nice)

@@ -976,6 +985,9 @@ def halomod_trispectrum_3h(cosmo, hmc, k, a, prof, *, prof2=None,
p_of_k_a (:class:`~pyccl.pk2d.Pk2D`): a `Pk2D` object to
be used as the linear matter power spectrum. If `None`, the power
spectrum stored within `cosmo` will be used.
separable_growth (Boolean): Indeicates whether a separable

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: Indeicates -> Indicates

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean -> bool

Copy link
Collaborator

@damonge damonge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @paulrogozenski ! Just a few typos (thanks @rreischke )

@@ -1303,6 +1335,9 @@ def halomod_Tk3D_2h(cosmo, hmc,
use_log (bool): if `True`, the trispectrum will be
interpolated in log-space (unless negative or
zero values are found).
separable_growth (Boolean): Indeicates whether a separable
growth function approximation can be used to calculate
the isotropized power spectrum.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeicates -> Indicates
Boolean -> bool

@@ -1396,6 +1432,9 @@ def halomod_Tk3D_3h(cosmo, hmc,
use_log (bool): if `True`, the trispectrum will be
interpolated in log-space (unless negative or
zero values are found).
separable_growth (Boolean): Indeicates whether a separable
growth function approximation can be used to calculate
the isotropized power spectrum.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indicates, bool

@@ -1469,6 +1509,9 @@ def halomod_Tk3D_4h(cosmo, hmc,
use_log (bool): if `True`, the trispectrum will be
interpolated in log-space (unless negative or
zero values are found).
separable_growth (Boolean): Indeicates whether a separable
growth function approximation can be used to calculate
the isotropized power spectrum.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indicates, bool

@@ -669,6 +670,9 @@ def halomod_trispectrum_2h_22(cosmo, hmc, k, a, prof, *, prof2=None,
p_of_k_a (:class:`~pyccl.pk2d.Pk2D`): a `Pk2D` object to
be used as the linear matter power spectrum. If `None`, the power
spectrum stored within `cosmo` will be used.
separable_growth (Boolean): Indeicates whether a separable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and Boolean -> bool for consistency (and so the docs look nice)

@@ -976,6 +985,9 @@ def halomod_trispectrum_3h(cosmo, hmc, k, a, prof, *, prof2=None,
p_of_k_a (:class:`~pyccl.pk2d.Pk2D`): a `Pk2D` object to
be used as the linear matter power spectrum. If `None`, the power
spectrum stored within `cosmo` will be used.
separable_growth (Boolean): Indeicates whether a separable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean -> bool

@@ -1140,6 +1159,9 @@ def halomod_trispectrum_4h(cosmo, hmc, k, a, prof, prof2=None, prof3=None,
p_of_k_a (:class:`~pyccl.pk2d.Pk2D`): a `Pk2D` object to
be used as the linear matter power spectrum. If `None`, the power
spectrum stored within `cosmo` will be used.
separable_growth (Boolean): Indeicates whether a separable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean -> bool

@@ -1553,6 +1598,9 @@ def halomod_Tk3D_cNG(cosmo, hmc, prof, prof2=None, prof3=None, prof4=None,
use_log (bool): if `True`, the trispectrum will be
interpolated in log-space (unless negative or
zero values are found).
separable_growth (Boolean): Indeicates whether a separable
growth function approximation can be used to calculate
the isotropized power spectrum.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indicates, bool

@damonge
Copy link
Collaborator

damonge commented Dec 4, 2024

Also, we need to add a unit test for this. Checking that you get the same result for some of this functions with or without scaling would be enough.

Copy link

@rreischke rreischke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, apart from the typo (as noted by @damonge ).

If the results agree, we can merge.

Copy link

@rreischke rreischke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks Paul!

@paulrogozenski paulrogozenski removed the request for review from carlosggarcia December 4, 2024 14:57
Copy link
Collaborator

@damonge damonge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@damonge damonge merged commit 406b548 into master Dec 4, 2024
4 checks passed
@damonge damonge deleted the cov_separable_growth branch December 4, 2024 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants