-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work on CCL module for cross-correlations (#16)
* Added CCL CosmologyCalculator functionality * Added CCL CosmologyCalculator functionality * Added notebook for testing * Added ccl likelihood * small changes * Dynamically importing ccl * Changed import back to top level * Renamed Tester likelihood and added data files * Change creation of CCL cosmo object * Change likelihood to use GaussianLikelihood structure * Removed old comments * Separate likelihood file and tests * Moved test file and other small changes * Removed python path * Updated example notebook * Updated assert statement * Changed max_tries * Increased tolerance of assert * fixed bug
- Loading branch information
1 parent
85a5e93
commit 0f8784e
Showing
11 changed files
with
1,040 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
auto_file: soliket/data/xcorr_simulated/clgg_noiseless.txt | ||
cross_file: soliket/data/xcorr_simulated/clkg_noiseless.txt | ||
dndz_file: soliket/data/xcorr_simulated/dndz.txt | ||
|
||
params: | ||
b1: | ||
prior: | ||
min: 0. | ||
max: 10. | ||
latex: b_1 | ||
s1: | ||
value: 0.4 | ||
latex: s_1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
""" | ||
Simple likelihood for CMB-galaxy cross-correlations using the cobaya | ||
CCL module. | ||
First version by Pablo Lemos | ||
""" | ||
|
||
import numpy as np | ||
from .gaussian import GaussianData, GaussianLikelihood | ||
import pyccl as ccl | ||
|
||
class CrossCorrelationLikelihood(GaussianLikelihood): | ||
def initialize(self): | ||
self.dndz = np.loadtxt(self.dndz_file) | ||
|
||
x,y,dy = self._get_data() | ||
cov = np.diag(dy**2) | ||
self.data = GaussianData("CrossCorrelation", x, y, cov) | ||
|
||
def get_requirements(self): | ||
return {'CCL': {"kmax": 10, | ||
"nonlinear": True}} | ||
|
||
def _get_data(self, **params_values): | ||
data_auto = np.loadtxt(self.auto_file) | ||
data_cross = np.loadtxt(self.cross_file) | ||
|
||
# Get data | ||
self.ell_auto = data_auto[0] | ||
cl_auto = data_auto[1] | ||
cl_auto_err = data_auto[2] | ||
|
||
self.ell_cross = data_cross[0] | ||
cl_cross = data_cross[1] | ||
cl_cross_err = data_cross[2] | ||
|
||
x = np.concatenate([self.ell_auto, self.ell_cross]) | ||
y = np.concatenate([cl_auto, cl_cross]) | ||
dy = np.concatenate([cl_auto_err, cl_cross_err]) | ||
|
||
return x, y, dy | ||
|
||
def _get_theory(self, **params_values): | ||
cosmo = self.provider.get_CCL()['cosmo'] | ||
|
||
tracer_g = ccl.NumberCountsTracer(cosmo, has_rsd=False, dndz = self.dndz.T, | ||
bias =(self.dndz[:,0], params_values['b1']*np.ones(len(self.dndz[:,0]))), | ||
mag_bias = (self.dndz[:,0], params_values['s1']*np.ones(len(self.dndz[:,0]))) | ||
) | ||
tracer_k = ccl.CMBLensingTracer(cosmo, z_source = 1060) | ||
|
||
cl_gg = ccl.cls.angular_cl(cosmo, tracer_g, tracer_g, self.ell_auto) #+ 1e-7 | ||
cl_kg = ccl.cls.angular_cl(cosmo, tracer_k, tracer_g, self.ell_cross) | ||
|
||
return np.concatenate([cl_gg, cl_kg]) | ||
|
||
def logp(self, **params_values): | ||
theory = self._get_theory(**params_values) | ||
return self.data.loglike(theory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
3.550000000000000000e+01 7.650000000000000000e+01 1.265000000000000000e+02 1.765000000000000000e+02 2.265000000000000000e+02 2.765000000000000000e+02 3.265000000000000000e+02 3.765000000000000000e+02 4.265000000000000000e+02 4.765000000000000000e+02 5.265000000000000000e+02 5.760000000000000000e+02 | ||
2.171386555992278359e-07 2.074818774537804928e-07 1.760569576742365607e-07 1.556208570083821835e-07 1.434590789832146224e-07 1.347070083607898911e-07 1.277731731363569596e-07 1.224832434049751676e-07 1.186677876068538790e-07 1.159080212760721562e-07 1.137746016890491462e-07 1.120196152233489823e-07 | ||
2.171386555992278359e-08 2.074818774537804994e-08 1.760569576742365674e-08 1.556208570083821835e-08 1.434590789832146224e-08 1.347070083607899044e-08 1.277731731363569629e-08 1.224832434049751775e-08 1.186677876068538790e-08 1.159080212760721661e-08 1.137746016890491529e-08 1.120196152233489823e-08 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
3.550000000000000000e+01 7.650000000000000000e+01 1.265000000000000000e+02 1.765000000000000000e+02 2.265000000000000000e+02 2.765000000000000000e+02 3.265000000000000000e+02 3.765000000000000000e+02 4.265000000000000000e+02 4.765000000000000000e+02 5.265000000000000000e+02 5.760000000000000000e+02 | ||
1.424982171873059867e-07 1.234732647730792034e-07 8.611508401982061149e-08 6.248438515784781822e-08 4.837007692483073317e-08 3.852305256406458136e-08 3.090458671774709724e-08 2.505965588344152354e-08 2.078012214338600926e-08 1.768136302352318810e-08 1.532330752048001726e-08 1.340720288202413845e-08 | ||
1.424982171873059966e-08 1.234732647730792068e-08 8.611508401982062142e-09 6.248438515784782318e-09 4.837007692483073648e-09 3.852305256406458467e-09 3.090458671774709973e-09 2.505965588344152520e-09 2.078012214338600843e-09 1.768136302352318975e-09 1.532330752048001851e-09 1.340720288202413845e-09 |
Oops, something went wrong.