Skip to content

Commit

Permalink
fixed bug in order of operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Sanchez authored and Javier Sanchez committed Feb 22, 2024
1 parent d9052e5 commit 7bc1ad2
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions augur/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, config, likelihood=None, tools=None, req_params=None):
self.lk = likelihood # Just to save some typing
self.tools = tools
self.req_params = req_params
self.data_fid = self.lk.get_data_vector()

_config = parse_config(config) # Load full config
# Get the fiducial cosmological parameters
Expand Down Expand Up @@ -190,7 +191,7 @@ def get_fisher_matrix(self, method='5pt_stencil'):
else:
return self.Fij

def compute_fisher_bias(self):
def get_fisher_bias(self):
# Compute Fisher bias following the generalized Amara formalism
# More details in Bianca's thesis and the note here:
# https://github.com/LSSTDESC/augur/blob/note_bianca/note/main.tex
Expand All @@ -199,8 +200,14 @@ def compute_fisher_bias(self):
# They should have the same ells as the original data-vector
# and the same length
import os

if self.derivatives is None:
self.get_derivatives()

if self.Fij is None:
self.get_fisher_matrix()

_calculate_biased_cls = True
_cls_fid = self.lk.get_data_vector() # Get the fiducial data vector

# Try to read the biased data vector
if 'biased_dv' in self.config['fisher_bias']:
Expand All @@ -220,7 +227,7 @@ def compute_fisher_bias(self):
raise ValueError('The length of the provided Cls should be equal \
to the length of the data-vector')
_calculate_biased_cls = False
self.biased_cls = biased_cls['dv_sys'] - _cls_fid
self.biased_cls = biased_cls['dv_sys'] - self.data_fid

# If there's no biased data vector, calculate it
if _calculate_biased_cls:
Expand All @@ -244,13 +251,8 @@ def compute_fisher_bias(self):
else:
raise ValueError('bias_params is required if no biased_dv file is passed')

self.biased_cls = self.f(_x_here, _labels_here, _pars_here, _sys_here) - _cls_fid
self.biased_cls = self.f(_x_here, _labels_here, _pars_here, _sys_here) - self.data_fid

if self.derivatives is None:
self.get_derivatives()
Bj = np.einsum('l, lm, jm', self.biased_cls, self.lk.inv_cov, self.derivatives)

if self.Fij is None:
self.get_fisher_matrix()
bi = np.einsum('ij, j', np.linalg.inv(self.Fij), Bj)
self.bi = bi

0 comments on commit 7bc1ad2

Please sign in to comment.