Skip to content

Commit

Permalink
Add Hartlap correction to CrossCorrelation likelihoods (#94)
Browse files Browse the repository at this point in the history
* added hartlap ncovsims to crosscorrelation

* Implement tests with tox-conda (#92)

* added configuration for tox-conda

* run tests with tox-conda

* data file locations and test skips

* make tests run in workflow

* add pytest-cov

* removed codestyle env typo

* added codestyle to envlist

* tox-conda version for codestyle

* added python version to codestyle workflow

* codestyle on 3.10 specifically

* flake8 fixes

* do not install everything for codestyle

* added temp fix for flaky sklearn install

* modified installation and testing instructions

* update action versions

* remove inapplicable parts of astropy cookie cutter, mention conda env in INSTALL.rst

* add make to conda deps

* test ncovsims

* added hartlap test
  • Loading branch information
itrharrison authored Feb 1, 2023
1 parent 7f6ec6a commit d3132da
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
2 changes: 2 additions & 0 deletions soliket/CrossCorrelationLikelihood.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ z_nuisance_mode: null
m_nuisance_mode: null
ia_mode: null

ncovsims: null

params:
b1:
prior:
Expand Down
4 changes: 2 additions & 2 deletions soliket/cross_correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(self):

x, y, dy = self._get_data()
cov = np.diag(dy**2)
self.data = GaussianData("CrossCorrelation", x, y, cov)
self.data = GaussianData("CrossCorrelation", x, y, cov, self.ncovsims)
else:
self._get_sacc_data()

Expand Down Expand Up @@ -53,7 +53,7 @@ def _get_sacc_data(self, **params_values):
self.y = self.sacc_data.mean
self.cov = self.sacc_data.covariance.covmat

self.data = GaussianData(self.name, self.x, self.y, self.cov)
self.data = GaussianData(self.name, self.x, self.y, self.cov, self.ncovsims)

def _construct_ell_bins(self):

Expand Down
40 changes: 40 additions & 0 deletions soliket/tests/test_cross_correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,46 @@ def test_shearkappa_like(request):
assert np.isclose(loglikes, 637.64473666)


def test_shearkappa_hartlap(request):

from soliket.cross_correlation import ShearKappaLikelihood

rootdir = request.config.rootdir

cs82_file = "soliket/tests/data/cs82_gs-planck_kappa_binned.sim.sacc.fits"
test_datapath = os.path.join(rootdir, cs82_file)

info["likelihood"] = {
"ShearKappaLikelihood": {"external": ShearKappaLikelihood,
"datapath": test_datapath}
}

# Cosmological parameters for the test data, digitized from
# Fig. 3 and Eq. 8 of Hall & Taylor (2014).
# See https://github.com/simonsobs/SOLikeT/pull/58 for validation plots
info['params'] = {"omch2": 0.118, # Planck + lensing + WP + highL
"ombh2": 0.0222,
"H0": 68.0,
"ns": 0.962,
# "As": 2.1e-9,
"As": 2.5e-9, # offset the theory to upweight inv_cov in loglike
"tau": 0.094,
"mnu": 0.0,
"nnu": 3.046,
"s1": 0.4,
"b1": 1.0}

model = get_model(info)
loglikes, derived = model.loglikes()

info["likelihood"]["ShearKappaLikelihood"]["ncovsims"] = 5

model = get_model(info)
loglikes_hartlap, derived = model.loglikes()

assert np.isclose(np.abs(loglikes - loglikes_hartlap), 0.00104092)


def test_shearkappa_deltaz(request):

from soliket.cross_correlation import ShearKappaLikelihood
Expand Down

0 comments on commit d3132da

Please sign in to comment.