Skip to content

Commit

Permalink
Merge pull request #1139 from LSSTDESC/bacco_lbias
Browse files Browse the repository at this point in the history
Bacco lbias
  • Loading branch information
matteozennaro authored Nov 28, 2023
2 parents 6b08a25 + 11192fa commit 265dd61
Show file tree
Hide file tree
Showing 6 changed files with 899 additions and 0 deletions.
70 changes: 70 additions & 0 deletions benchmarks/data/pt_bm_bacco_lbias_z0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
1.000000000000000048e-04 6.855035589030412957e+06 1.731322507686917903e+06
1.125017868369810811e-04 6.305171508418726735e+06 1.582594949291167548e+06
1.265665204151353231e-04 5.785967353791039437e+06 1.442792104142579250e+06
1.423895970044196770e-04 5.296550671375462785e+06 1.311645761624566978e+06
1.601908408999486275e-04 4.836049007399951108e+06 1.188887711121035740e+06
1.802175583616277257e-04 4.403589908092526719e+06 1.074249742015381111e+06
2.027479733508104082e-04 3.998300919680489227e+06 9.674636436908420874e+05
2.280950927954279619e-04 3.619309588390721940e+06 8.682612055304173846e+05
2.566110550823265716e-04 3.265743460452281870e+06 7.763742169183804654e+05
2.886920221888471748e-04 2.936730082092395518e+06 6.915344672377756797e+05
3.247836834182669485e-04 2.631396999538830481e+06 6.134737458721853327e+05
3.653874472005138197e-04 2.348871759019009769e+06 5.419238422048285138e+05
4.110674069786092737e-04 2.088281906761171995e+06 4.766165456194913713e+05
4.624581779553800964e-04 1.848754988992715254e+06 4.172836454994115629e+05
5.202737135735483647e-04 1.629418551941404119e+06 3.636569312280857121e+05
5.853172242133589456e-04 1.429400141835035989e+06 3.154681921889922814e+05
6.584923359046477350e-04 1.247827304901328404e+06 2.724492177655681735e+05
7.408156440773042140e-04 1.083827587368055945e+06 2.343317973413098371e+05
8.334308367548572648e-04 9.365285354628558271e+05 2.008477202996404667e+05
9.376245833996174270e-04 8.050576954135099659e+05 1.717287760240163479e+05
1.054844410147369503e-03 6.885426134477542946e+05 1.467067538979064557e+05
1.186718809765804124e-03 5.861108357931714272e+05 1.255134433046632039e+05
1.335079865717084041e-03 4.968899086777408957e+05 1.078806336279096286e+05
1.501988704632487232e-03 4.200073783289733692e+05 9.354011425096351013e+04
1.689764130801174212e-03 3.545907909746699152e+05 8.222367455732729286e+04
1.901014840481703464e-03 2.997676928425814258e+05 7.366310393046194804e+04
2.138675663578101793e-03 2.546656301604587352e+05 6.759019175383858965e+04
2.406048336173026957e-03 2.184121491559549759e+05 6.373672741086473252e+04
2.706847370356106099e-03 1.901347960568578856e+05 6.183450028503002977e+04
3.045251658600457711e-03 1.689611170908559870e+05 6.161529975976930291e+04
3.425962529608314513e-03 1.540186584857124253e+05 6.281091521855384053e+04
3.854269062174795271e-03 1.444349664691298094e+05 6.515313604482416122e+04
4.336121564451593177e-03 1.393375872688434902e+05 6.837375162203848595e+04
4.878214239431705873e-03 1.378540671125804947e+05 7.220455133365021902e+04
5.488078185096710929e-03 1.391119522280704114e+05 7.637732456311455462e+04
6.174186021244368154e-03 1.422387888430423627e+05 8.062386069388614851e+04
6.946069596539016129e-03 1.463621231852223282e+05 8.467594910941817216e+04
7.814452411046684047e-03 1.506095014823389938e+05 8.826537919316513580e+04
8.791398593953060961e-03 1.541084699621199979e+05 9.112394032858090941e+04
9.890480506158424306e-03 1.562512351973984623e+05 9.303400141059812449e+04
1.112696729619151899e-02 1.570776950108758174e+05 9.388496726643192233e+04
1.251803702898198097e-02 1.560964727966866922e+05 9.339143319992923352e+04
1.408301533451966799e-02 1.530083412248911336e+05 9.138866302858100971e+04
1.584364389186067659e-02 1.478099369707513251e+05 8.778123262820804666e+04
1.782438247843147125e-02 1.406713264526355197e+05 8.271700102806974610e+04
2.005274878089318216e-02 1.318069295894066454e+05 7.639847539796734054e+04
2.255970068843577217e-02 1.218050505921091826e+05 6.925515076792147011e+04
2.538006637956496600e-02 1.115507349460478581e+05 6.193308795112917142e+04
2.855302817742248062e-02 1.018606175297661539e+05 5.513927801614269265e+04
3.212266689566698613e-02 9.343733965296312817e+04 4.933937925436145451e+04
3.613857423731676316e-02 8.667749094105955737e+04 4.492700872193000396e+04
4.065654175439026990e-02 8.118331846965101431e+04 4.146428609593502188e+04
4.573933593981235196e-02 7.589140657157383976e+04 3.826747317999914230e+04
5.145757021965836897e-02 6.968134210939257173e+04 3.432066468152480229e+04
5.789068596000986056e-02 6.218479290794593544e+04 2.943168996150249950e+04
6.512805611719643673e-02 5.468021221455463092e+04 2.454961468407437860e+04
7.327022686403775187e-02 4.844426069067248318e+04 2.091755571477606281e+04
8.243031444155220211e-02 4.383208375223904295e+04 1.867093857859003037e+04
9.273557664208829932e-02 3.990856214840315806e+04 1.664717399621781078e+04
1.043291807559273976e-01 3.563047891117057588e+04 1.425023996776120293e+04
1.173721925428021368e-01 3.185891197906968591e+04 1.226188214779403825e+04
1.320458138603942677e-01 2.915394661601902044e+04 1.099675414611043561e+04
1.485539000363775841e-01 2.643317288311504672e+04 9.710702582257510585e+03
1.671257919569474892e-01 2.400396424968933570e+04 8.614309544499872572e+03
1.880195022170215446e-01 2.193334960257961939e+04 7.742739802899634014e+03
2.115252995961465210e-01 2.007347703997483040e+04 6.967392010316811138e+03
2.379697416579423519e-01 1.846920023339546606e+04 6.327384991037761210e+03
2.677202114965329116e-01 1.708514059014760278e+04 5.777041934382074032e+03
3.011900216573443756e-01 1.589338777559453592e+04 5.309448138988474966e+03
3.388441561392025458e-01 1.486986077699188718e+04 4.904235139092390455e+03
70 changes: 70 additions & 0 deletions benchmarks/data/pt_bm_bacco_lbias_z1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
1.000000000000000048e-04 -5.787538347034783801e+05 -5.760465749232481467e+05
1.125017868369810811e-04 -5.399584957598655019e+05 -5.363730526740099303e+05
1.265665204151353231e-04 -5.027504697382528102e+05 -4.984428364051764365e+05
1.423895970044196770e-04 -4.670977722293614643e+05 -4.622170264950743876e+05
1.601908408999486275e-04 -4.329684188237880589e+05 -4.276567233218124602e+05
1.802175583616277257e-04 -4.003304251122052083e+05 -3.947230272636098671e+05
2.027479733508104082e-04 -3.691518066854010685e+05 -3.633770386987907114e+05
2.280950927954279619e-04 -3.394005791342977900e+05 -3.335798580057563377e+05
2.566110550823265716e-04 -3.110447580495520961e+05 -3.052925855627732235e+05
2.886920221888471748e-04 -2.840523590216873563e+05 -2.784763217479078448e+05
3.247836834182669485e-04 -2.583913976416455116e+05 -2.530921669395852659e+05
3.653874472005138197e-04 -2.340298895001568599e+05 -2.291012215160999040e+05
4.110674069786092737e-04 -2.109358501878337993e+05 -2.064645858555978339e+05
4.624581779553800964e-04 -1.890772952954104985e+05 -1.851433603363852890e+05
5.202737135735483647e-04 -1.684222404137553240e+05 -1.650986453368044167e+05
5.853172242133589456e-04 -1.489387011335245916e+05 -1.462915412350882252e+05
6.584923359046477350e-04 -1.305946930453853856e+05 -1.286831484094547632e+05
7.408156440773042140e-04 -1.133582317401100008e+05 -1.122345672382037301e+05
8.334308367548572648e-04 -9.719733280848342110e+04 -9.690689809963956941e+04
9.376245833996174270e-04 -8.208001184116789955e+04 -8.266124137198489916e+04
1.054844410147369503e-03 -6.797428442893552710e+04 -6.945869743353693048e+04
1.186718809765804124e-03 -5.484816616253430402e+04 -5.726036666257845354e+04
1.335079865717084041e-03 -4.266967263262737106e+04 -4.602734943732642569e+04
1.501988704632487232e-03 -3.140681943000727551e+04 -3.572074613609736844e+04
1.689764130801174212e-03 -2.102762214539703564e+04 -2.630165713715392849e+04
1.901014840481703464e-03 -1.150009636950433014e+04 -1.773118281874665990e+04
2.138675663578101793e-03 -2.792257693070999721e+03 -9.970423559155035036e+03
2.406048336173026957e-03 5.127878293163939816e+03 -2.980479736651973781e+03
2.706847370356106099e-03 1.229229599847857935e+04 3.277548270499342379e+03
3.045251658600457711e-03 1.873297983213460975e+04 8.842560084024857133e+03
3.425962529608314513e-03 2.448191420340646437e+04 1.375345532565876601e+04
3.854269062174795271e-03 2.957108352155875764e+04 1.804913361712914411e+04
4.336121564451593177e-03 3.403247219586047140e+04 2.176849458016718927e+04
4.878214239431705873e-03 3.789806463558069663e+04 2.495043783650359183e+04
5.488078185096710929e-03 4.119984524998840061e+04 2.763386300786942229e+04
6.174186021244368154e-03 4.396979844835220865e+04 2.985766971599531462e+04
6.946069596539016129e-03 4.623990863994021493e+04 3.166075758261149167e+04
7.814452411046684047e-03 4.804216023402116116e+04 3.308202622944871837e+04
8.791398593953060961e-03 4.940853763986354897e+04 3.416037527823755954e+04
9.890480506158424306e-03 5.034065830618274776e+04 3.490851339100255427e+04
1.112696729619151899e-02 5.071714106207974692e+04 3.523463415399403311e+04
1.251803702898198097e-02 5.043450745832359098e+04 3.505944959891346662e+04
1.408301533451966799e-02 4.941743802003123710e+04 3.432452220551073697e+04
1.584364389186067659e-02 4.762556696446789283e+04 3.299835495910294412e+04
1.782438247843147125e-02 4.509617248215829750e+04 3.111436246673823553e+04
2.005274878089318216e-02 4.190430272682777286e+04 2.872576903427655270e+04
2.255970068843577217e-02 3.832294702413521009e+04 2.605077494000550723e+04
2.538006637956496600e-02 3.459748322807742079e+04 2.326410160910756531e+04
2.855302817742248062e-02 3.110758490381195224e+04 2.067548204131027524e+04
3.212266689566698613e-02 2.810810286775376881e+04 1.846723907944000166e+04
3.613857423731676316e-02 2.576981973068406296e+04 1.677732809927342532e+04
4.065654175439026990e-02 2.393682114865565381e+04 1.547656622730936397e+04
4.573933593981235196e-02 2.224548790820713839e+04 1.429676701664213215e+04
5.145757021965836897e-02 2.012452510844651988e+04 1.278113062405563323e+04
5.789068596000986056e-02 1.743829033173220159e+04 1.083803095979534010e+04
6.512805611719643673e-02 1.462507993024422467e+04 8.802395076095741388e+03
7.327022686403775187e-02 1.252046963015262190e+04 7.316186139403020206e+03
8.243031444155220211e-02 1.128591522795189303e+04 6.518127387715445366e+03
9.273557664208829932e-02 1.013164123800368179e+04 5.779984140146171740e+03
1.043291807559273976e-01 8.633057393865612539e+03 4.757156171246198028e+03
1.173721925428021368e-01 7.322863391620325274e+03 3.886577755426259500e+03
1.320458138603942677e-01 6.576447003548580142e+03 3.434331748271198649e+03
1.485539000363775841e-01 5.697144779268932325e+03 2.885211845994848773e+03
1.671257919569474892e-01 4.946280733547519048e+03 2.429306315553752029e+03
1.880195022170215446e-01 4.359654143806421416e+03 2.096614094600254248e+03
2.115252995961465210e-01 3.807726728444853507e+03 1.783181421621180107e+03
2.379697416579423519e-01 3.353523843515297358e+03 1.537292786463995981e+03
2.677202114965329116e-01 2.956444373898936192e+03 1.327618530470946098e+03
3.011900216573443756e-01 2.620988530749326856e+03 1.154202125870107466e+03
3.388441561392025458e-01 2.334633412620704803e+03 1.010505217137959335e+03
57 changes: 57 additions & 0 deletions benchmarks/test_ptpk_bacco_lbias.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import os
import numpy as np
import pyccl as ccl
import pyccl.nl_pt as pt
import pytest

LPTPK_TOLERANCE = 1e-4

# Set cosmology
COSMO = ccl.Cosmology(Omega_c=0.25, Omega_b=0.05,
h=0.7, sigma8=0.8, n_s=0.96)

# Redshifts
zs = np.array([0., 1.])

# Tracers
ptt = {}
ptt['g'] = pt.PTNumberCountsTracer(b1=1.3, b2=1.5, bs=1.7, bk2=0.1)
ptt['m'] = pt.PTMatterTracer()

# Calculator
a_arr = 1./(1+np.array([0., 0.25, 0.5, 0.75, 1.]))[::-1]
ptc = pt.BaccoLbiasCalculator(log10k_min=-4, log10k_max=-0.47,
nk_per_decade=20, a_arr=a_arr)

ptc.update_ingredients(COSMO)

# Read data
dirdat = os.path.join(os.path.dirname(__file__), 'data')
data = []
data.append(np.loadtxt(os.path.join(dirdat, 'pt_bm_bacco_lbias_z0.txt'),
unpack=True))
data.append(np.loadtxt(os.path.join(dirdat, 'pt_bm_bacco_lbias_z1.txt'),
unpack=True))
order = ['gg', 'gm']


@pytest.mark.parametrize('comb', enumerate(order))
def test_pt_pk(comb):
i_d, cc = comb
t1, t2 = cc

ptt1 = ptt[t1]
ptt2 = ptt[t2]

pk = ptc.get_biased_pk2d(ptt1, tracer2=ptt2)

for iz, z in enumerate(zs):
a = 1./(1+z)
kin = data[iz][0]
ind = np.where((kin < 1.0) & (kin > 1E-3))
k = kin[ind]
dpk = data[iz][i_d+1][ind]
tpk = pk(k, a, COSMO)
assert np.all(
np.fabs(tpk / dpk - 1) < LPTPK_TOLERANCE
)
1 change: 1 addition & 0 deletions pyccl/nl_pt/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .tracers import *
from .ept import *
from .lpt import *
from .bacco_lbias import *
Loading

0 comments on commit 265dd61

Please sign in to comment.