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

PT biases in v3 #1056

Merged
merged 19 commits into from
Apr 16, 2023
Merged

PT biases in v3 #1056

merged 19 commits into from
Apr 16, 2023

Conversation

damonge
Copy link
Collaborator

@damonge damonge commented Apr 2, 2023

The usage of the new PT module would be as follows:

cosmo = ccl.CosmologyVanillaLCDM()

# Initialize a perturbation theory calculator
ptc = ccl.nl_pt.EulerianPTCalculator(with_NC=True, cosmo=cosmo)

# If you need to update the PT P(k) kernels to a new cosmology:
ptc.update_ingredients(cosmo)

# Now you can calculate biased power spectra, e.g.:
tg = ccl.nl_pt.PTNumberCountsTracer(b1=1.0, b2=0.5)
tm = ccl.nl_pt.PTMatterTracer()
pk_gg = ptc.get_pk2d_biased(tg, tracer2=tg)
pk_gm = ptc.get_pk2d_biased(tg, tracer2=tm)

# You can also ask for specific P(k) templates.
# E.g. this will get you the <delta * s^2> template
pk_d1_s2 = ptc.get_pk2d_template('b1:bs')

@coveralls
Copy link

coveralls commented Apr 2, 2023

Pull Request Test Coverage Report for Build 4595207464

  • 2909 of 2948 (98.68%) changed or added relevant lines in 70 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.03%) to 97.894%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pyccl/halos/concentration/concentration_base.py 42 43 97.67%
pyccl/halos/concentration/constant.py 18 19 94.74%
pyccl/halos/concentration/diemer15.py 42 43 97.67%
pyccl/halos/concentration/ishiyama21.py 131 132 99.24%
pyccl/halos/hbias/bhattacharya11.py 24 25 96.0%
pyccl/halos/hbias/sheth01.py 25 26 96.15%
pyccl/halos/hmfunc/angulo12.py 21 22 95.45%
pyccl/halos/hmfunc/jenkins01.py 20 21 95.24%
pyccl/halos/hmfunc/press74.py 20 21 95.24%
pyccl/base/caching.py 161 163 98.77%
Files with Coverage Reduction New Missed Lines %
pyccl/core.py 1 95.74%
pyccl/covariances.py 1 98.59%
Totals Coverage Status
Change from base Build 4577061095: 0.03%
Covered Lines: 6042
Relevant Lines: 6172

💛 - Coveralls

@damonge damonge marked this pull request as ready for review April 3, 2023 10:01
@damonge damonge changed the base branch from master to v3_wip April 3, 2023 10:02
@anicola
Copy link
Contributor

anicola commented Apr 3, 2023

Thanks a lot @damonge! I haven't looked much at the IAs as I am not so familiar with it, but pgg ang pgm look good to me! Just to check - this assumes that stochasticity will be handled outside CCL, right?

pyccl/nl_pt/ept.py Show resolved Hide resolved
pyccl/nl_pt/__init__.py Show resolved Hide resolved
Copy link
Contributor

@nikfilippas nikfilippas left a comment

Choose a reason for hiding this comment

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

A quick comment.

pyccl/nl_pt/power_deprecated.py Outdated Show resolved Hide resolved
@damonge
Copy link
Collaborator Author

damonge commented Apr 3, 2023

@anicola Good point. Yes, indeed, I've added a note about stochastic bias in the docstring.

Copy link
Contributor

@nikfilippas nikfilippas left a comment

Choose a reason for hiding this comment

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

'Some' comments mainly regarding naming, efficiency, and consistency.

pyccl/nl_pt/ept.py Outdated Show resolved Hide resolved
pyccl/nl_pt/ept.py Outdated Show resolved Hide resolved
pyccl/nl_pt/ept.py Outdated Show resolved Hide resolved
pyccl/nl_pt/ept.py Outdated Show resolved Hide resolved
pyccl/nl_pt/ept.py Outdated Show resolved Hide resolved
pyccl/tests/test_ept_power.py Outdated Show resolved Hide resolved
pyccl/tests/test_ept_power.py Outdated Show resolved Hide resolved
pyccl/nl_pt/tracers.py Show resolved Hide resolved
pyccl/nl_pt/ept.py Outdated Show resolved Hide resolved
pyccl/nl_pt/ept.py Outdated Show resolved Hide resolved
@nikfilippas nikfilippas mentioned this pull request Apr 5, 2023
34 tasks
@damonge
Copy link
Collaborator Author

damonge commented Apr 6, 2023

Back to you @nikfilippas

Copy link
Contributor

@nikfilippas nikfilippas left a comment

Choose a reason for hiding this comment

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

A final comment, and we have the unresolved ones remaining.

pyccl/nl_pt/ept.py Show resolved Hide resolved
pyccl/nl_pt/ept.py Outdated Show resolved Hide resolved
pyccl/nl_pt/ept.py Outdated Show resolved Hide resolved
pyccl/tests/test_ept_power.py Outdated Show resolved Hide resolved
@nikfilippas nikfilippas linked an issue Apr 9, 2023 that may be closed by this pull request
@damonge
Copy link
Collaborator Author

damonge commented Apr 16, 2023

All done, back to you @nikfilippas

Copy link
Contributor

@nikfilippas nikfilippas left a comment

Choose a reason for hiding this comment

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

There are 4 uncovered lines. Do you think we can cover the last 3 of them? I'm approving either way.

@damonge
Copy link
Collaborator Author

damonge commented Apr 16, 2023

All should be covered now.

@nikfilippas
Copy link
Contributor

@damonge you do the honours

@damonge damonge merged commit d5ed640 into v3_wip Apr 16, 2023
@damonge damonge deleted the nl_pt_v3 branch April 16, 2023 15:32
damonge added a commit that referenced this pull request May 3, 2023
* halo profiles in their own directory

* concentrations in their own directory

* mass functions & halo biases in their own directory

* moved CIB stuff to profiles & 2pts

* split halo model into 1/2/4-pt

* fix imports

* remove empty module

* fix typo

* Baryons in v3 (#1039)

* Added new baryons module that will deprecate old BCM

* Tracers v3 (#1040)

* Tracers in V3

* Background, boltzmann, and cls in v3 (#1041)

* Background, boltzmann and cls in v3

* Covariances in v3 (#1046)

* Covariances in V3

* Correlations v3 (#1042)

* Correlations in v3

* split base.py and restructured into its own dir to simplify

* Neutrinos, parameters, power in v3 (#1047)

* done

* Make `T_ncdm` a cosmological parameter + (v3) (#1049)

* first commit

* rename TNCDM to T_ncdm but preserve API

* T_CMB directly into cosmo struct

* Omega_g in ccl_parameters_create; no split between C/Python

* physical_constants.T_CMB doesn't mutate anymore!

* force mutate T_CMB in benchmarks

* define defaults on instantiation just in case constants mutate

* A_s & sigma8: don't play with numbers

* simplify

* remove leftover mallocs

* temporarily preserve API for CCLv3

* Unfreeze option for `physical_constants` (#1050)

* first commit

* update rtd

* addressed comments 1

* Remove `T_CMB` and `T_ncdm` as constants (reloaded) (#1058)

* first commit

* OmNuh2 fix

* addressed comments

* keep only massive

* first step

* temp commit

* debug neutrinos & deprecate Omnuh2

* ccl_omega_x & ccl_Omeganuh2 consistency

---------

Co-authored-by: David Alonso <[email protected]>

* RTD: Removed The Docs

---------

Co-authored-by: David Alonso <[email protected]>

* flaked

---------

Co-authored-by: Nick Koukoufilippas <[email protected]>

* Pk2D and Tk3D in v3 (#1048)

* tk3d and pk2d in v3

---------

Co-authored-by: Nick Koukoufilippas <[email protected]>

* PT biases in v3 (#1056)

* New PT bias framework

* Halos v3 (#1043)

* ported changes in halos/profiles

* changes from star in halos/ (no tests)

* refactor concentration, mass_function, halo_bias; improvements in HMCalculator

* HaloProfile subclasses & HaloProfile.normprof attribute

* simplify imports

* remove HaloProfile.name

* cleaned up pk_Npt

* add extrap_pk argument

* FFTLogParams class instead of dictionary in HaloProfile

* simplified code

* removed mass_def from HMIngredients; comprehensive code review 1

* re-implementation, bugfixes, tests

* c_m_relation >> concentration; code improvements; A_SPLINE_MAX in Python

* HMIngredients initializers - no repeated code

* rogue file

* patch for new changes

* updated Build Status badge website

* fix websites

* added a DOI badge & links

* added nonbreaking space

* removed extra space

* FancyRepr out of CCLObject to simplify

* update tests to match changes

* coverage

* simple test for tkkssc

* more tests for tkkssc

* addressed comments 1

* addressed comments 2: mass_def defaults are name strings etc.

* deprecate Gaussian & PowerLaw profiles

* bugfix in master: sometimes mass_def_strict=False fails unexpectedly

* typo

* addressed comments

* New feature: Arbitrary function for profile normalization

* gain efficiency

* comments + deprecate k_min from HMCalculator

* renamed initialize_from_input --> create_instance

* brought in CCLNamedClass from docs_v3

* brought in from docs_v3: directly callable HMIngredients

* prep for Davids input

* renamed HMCalculator --> HaloModel

* fix typo

* brought in from docs_v3: initialize mass_def from any string (e.g. 400c)

* Revert "renamed HMCalculator --> HaloModel"

This reverts commit 43591ce.

* counterterms func inside of 4pt func

* replace deprecated abstractproperty

* abstract linked methods for HaloProfile, MassFunc, HaloBias, Concentration

* fully working implementation

* renamed lM --> log10M etc.

* minor cosmetic fix

* alternative way to include linked abstract methods and declare the template methods

* reorder

* even simpler

* bring back eq_attrs

* r -> r_t

* Additional halos features (#1068)

* first commit

* enclose classmethods in the class

* brought in minor improvements to halos

* coverage

* Tests v3 (#1059)

* ported changes in halos/profiles

* changes from star in halos/ (no tests)

* refactor concentration, mass_function, halo_bias; improvements in HMCalculator

* HaloProfile subclasses & HaloProfile.normprof attribute

* simplify imports

* remove HaloProfile.name

* cleaned up pk_Npt

* add extrap_pk argument

* FFTLogParams class instead of dictionary in HaloProfile

* simplified code

* removed mass_def from HMIngredients; comprehensive code review 1

* re-implementation, bugfixes, tests

* c_m_relation >> concentration; code improvements; A_SPLINE_MAX in Python

* HMIngredients initializers - no repeated code

* rogue file

* patch for new changes

* updated Build Status badge website

* fix websites

* added a DOI badge & links

* added nonbreaking space

* removed extra space

* FancyRepr out of CCLObject to simplify

* update tests to match changes

* coverage

* simple test for tkkssc

* more tests for tkkssc

* addressed comments 1

* addressed comments 2: mass_def defaults are name strings etc.

* deprecate Gaussian & PowerLaw profiles

* remove all warnings in testing

* use pytest as per docs instead of numpy.testing and pyutils.assert_warns

* bugfix in master: sometimes mass_def_strict=False fails unexpectedly

* typo

* addressed comments

* New feature: Arbitrary function for profile normalization

* gain efficiency

* comments + deprecate k_min from HMCalculator

* renamed initialize_from_input --> create_instance

* brought in CCLNamedClass from docs_v3

* brought in from docs_v3: directly callable HMIngredients

* prep for Davids input

* renamed HMCalculator --> HaloModel

* fix typo

* brought in from docs_v3: initialize mass_def from any string (e.g. 400c)

* Revert "renamed HMCalculator --> HaloModel"

This reverts commit 43591ce.

* comments

* comments

* shortcut for __eq__ methods

* Eq. for EulerianPT calculator (#1073)

* __eq_attrs__ for nl_pt

* No normprof (#1072)

* extricated normprof

* Cosmology v3 (#1071)

* rename core --> Cosmology

* renamed core --> cosmology in docs/imports except docstrings

* cosmology v2

* first pass

* neutrinosneutrinosneutrinos

* simplified

* yamlyamlyaml

* fully fix neutrino mayhem

* new arg names in tests

* comments

* comments on comments on comments

* removed tests

* no warn

---------

Co-authored-by: David Alonso <[email protected]>

* avoid warning due to zeros (#1076)

* Fix halo inconsistencies v3 (#1069)

* ported changes in halos/profiles

* changes from star in halos/ (no tests)

* refactor concentration, mass_function, halo_bias; improvements in HMCalculator

* HaloProfile subclasses & HaloProfile.normprof attribute

* simplify imports

* remove HaloProfile.name

* cleaned up pk_Npt

* add extrap_pk argument

* FFTLogParams class instead of dictionary in HaloProfile

* simplified code

* removed mass_def from HMIngredients; comprehensive code review 1

* re-implementation, bugfixes, tests

* c_m_relation >> concentration; code improvements; A_SPLINE_MAX in Python

* HMIngredients initializers - no repeated code

* rogue file

* patch for new changes

* updated Build Status badge website

* fix websites

* added a DOI badge & links

* added nonbreaking space

* removed extra space

* FancyRepr out of CCLObject to simplify

* update tests to match changes

* coverage

* simple test for tkkssc

* more tests for tkkssc

* addressed comments 1

* addressed comments 2: mass_def defaults are name strings etc.

* deprecate Gaussian & PowerLaw profiles

* bugfix in master: sometimes mass_def_strict=False fails unexpectedly

* typo

* addressed comments

* New feature: Arbitrary function for profile normalization

* gain efficiency

* comments + deprecate k_min from HMCalculator

* renamed initialize_from_input --> create_instance

* brought in CCLNamedClass from docs_v3

* brought in from docs_v3: directly callable HMIngredients

* prep for Davids input

* renamed HMCalculator --> HaloModel

* fix typo

* brought in from docs_v3: initialize mass_def from any string (e.g. 400c)

* Revert "renamed HMCalculator --> HaloModel"

This reverts commit 43591ce.

* counterterms func inside of 4pt func

* replace deprecated abstractproperty

* abstract linked methods for HaloProfile, MassFunc, HaloBias, Concentration

* fully working implementation

* renamed lM --> log10M etc.

* minor cosmetic fix

* first commit

* alternative way to include linked abstract methods and declare the template methods

* reorder

* even simpler

* enclose classmethods in the class

* brought in minor improvements to halos

* clone of 1064

* bring back eq_attrs

* r -> r_t

* Additional halos features (#1068)

* first commit

* enclose classmethods in the class

* brought in minor improvements to halos

* coverage

* removed MassConcentration

* full implementation (v3 only)

* comments

* single-liner

* coverage

* Final checklist v3 (#1075)

* imports

* homogenize all imports as per PEP8 and the Python Import System

* homogenize all imports as per PEP8 and the Python Import System

* instance checks

* all exceptions raised correctly

* comments

* add aliases

* reverted changes and introduced proper enums

* Preserve API in v2.final (#1077)

* first commit

* Einasto mass translator + MassDef concentration API

* universal api no-break

* comments

* MassDef vars

* Coverage v3 (#1078)

* coverage

* comments

---------

Co-authored-by: David Alonso <[email protected]>
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.

sub_lowk option for P_II
5 participants