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

Fisher bias #30

Merged
merged 43 commits into from
Jan 30, 2024
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
dc9ed1f
augur/analyze.py
Apr 8, 2022
382d313
independent bias implementation
Apr 8, 2022
c7b352a
trying to fix flake8 issues
Apr 8, 2022
7d7465b
added some fixes
Apr 13, 2022
03caa5e
more wip
Apr 13, 2022
2bcd834
restructured some code but still not working
Apr 14, 2022
3932f85
added example contaminated dv
Apr 14, 2022
6e7de28
Implementing delta_ell=1 stuff
Apr 22, 2022
cab8eb5
kinda working version -- the results are off
Apr 25, 2022
1447edf
fixed bug in delta_ell
Apr 26, 2022
07c03b9
Trying to fix flake8
Apr 26, 2022
05428e7
fixing CI
Apr 26, 2022
b65d1ed
updated instructions
fjaviersanchez Sep 16, 2022
5c0941c
1st working version of fisher derivatives
Nov 15, 2023
4cc4de9
merged conficts
Nov 15, 2023
80211eb
Working version of Analyze
Nov 15, 2023
0e4aa0f
generalizing auxiliary function
Nov 15, 2023
d0eedea
working Fisher matrices and biases
Nov 15, 2023
f664f70
fixed bugs, updated config
Nov 15, 2023
9fb750b
changing default config to try to compare with SRD Fisher
Nov 16, 2023
a26da4f
fixed small bug and linter
fjaviersanchez Nov 24, 2023
6a1b4e4
Added calculation of biased data vector
fjaviersanchez Nov 24, 2023
96ae4f2
fixing bugs
fjaviersanchez Nov 24, 2023
7f246fc
more bugfixes
fjaviersanchez Nov 24, 2023
8d0a5b5
more bugfixes
fjaviersanchez Nov 24, 2023
46a0e58
trying to fix CI
fjaviersanchez Nov 24, 2023
ec92500
trying to fix CI
fjaviersanchez Nov 24, 2023
401b2a5
simplifying CI for now
fjaviersanchez Nov 24, 2023
a10b84d
further simplifying CI
fjaviersanchez Nov 24, 2023
0e851e9
fixing flake8
fjaviersanchez Nov 24, 2023
e84daad
added back numdifftools
Nov 27, 2023
ab00761
merged changes from master
Jan 26, 2024
e1ab7ff
fixing after update
Jan 29, 2024
b95ca53
fixed deleted line
Jan 29, 2024
28f55d5
fixed tests
Jan 29, 2024
667e490
linting
Jan 29, 2024
6008735
fixing CI
Jan 29, 2024
22fc301
fixing CI
Jan 29, 2024
424571e
trying to fix CI
Jan 30, 2024
629126c
trying to fix CI
Jan 30, 2024
08b3b5c
trying to fix CI
Jan 30, 2024
9d93f9d
trying to fix CI
Jan 30, 2024
747d9e2
fixed CI + updated version string
Jan 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added calculation of biased data vector
fjaviersanchez committed Nov 24, 2023
commit 6a1b4e4e7b93659073dfcff211180b1fd7c1fe5e
46 changes: 36 additions & 10 deletions augur/analyze.py
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@ def __init__(self, config, likelihood=None, tools=None, req_params=None):
self.derivatives = None
self.Fij = None
self.bi = None
self.biased_cls = None
# Load the parameters to vary
# We will allow 2 options -- one where we pass something
# a la cosmosis with parameters and minimum, central, and max
@@ -183,8 +184,11 @@ def compute_fisher_bias(self):
# and the same length
import os
_calculate_biased_cls = True
if 'cl_sys' in self.config['fisher_bias']:
_sys_path = self.config['fisher_bias']['cl_sys']
_cls_fid = self.lk.measured_data_vector # Get the fiducial data vector

# Try to read the biased data vector
if 'biased_dv' in self.config['fisher_bias']:
_sys_path = self.config['fisher_bias']['biased_dv']
if (len(_sys_path) < 1) or (os.path.exists(_sys_path) is False):
_calculate_biased_cls = True
else:
@@ -200,15 +204,37 @@ 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

# If there's no biased data vector, calculate it
if _calculate_biased_cls:
raise NotImplementedError('To compute the biased Cls use external software \
for the moment.')
else:
if self.derivatives is None:
self.get_derivatives()
Bj = np.einsum('l, lm, jm', biased_cls['cl_sys'], self.lk.inv_cov, self.derivatives)
if self.Fij is None:
self.get_fisher_matrix()
_x_here = []
_labels_here = []
if 'bias_params' in self.config['fisher_bias'].keys():
_pars_here = self.var_pars().copy()
_sys_here = self.req_params().copy()
for key, value in self.config['fisher_bias']['bias_params'].items():
if key in _pars_here.keys():
_pars_here[key] = value
_x_here.append(value)
_labels_here.append(key)
elif key in _sys_here.keys():
_sys_here[key] = value
_x_here.append(value)
_labels_here.append(key)
else:
raise ValueError(f'The requested parameter `{key}` is not recognized. \
Please make sure that it is part of your model.')
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

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
14 changes: 11 additions & 3 deletions examples/config_test.yml
Original file line number Diff line number Diff line change
@@ -86,7 +86,9 @@ cov_options:
fisher:
var_pars: ['Omega_c', 'sigma8', 'n_s', 'w0', 'wa', 'Omega_b', 'h', 'lens0_bias', 'lens1_bias',
'lens2_bias', 'lens3_bias', 'lens4_bias',
'src0_mult_bias', 'src1_mult_bias', 'src2_mult_bias', 'src3_mult_bias', 'src4_mult_bias']
'src0_mult_bias', 'src1_mult_bias', 'src2_mult_bias', 'src3_mult_bias', 'src4_mult_bias',
'lens0_delta_z', 'lens1_delta_z', 'lens2_delta_z', 'lens3_delta_z', 'lens4_delta_z',
'src0_delta_z', 'src1_delta_z', 'src2_delta_z', 'src3_delta_z', 'src4_delta_z']
# parameters: # TODO: For now priors are ignored
# Omega_c: [0.1, 0.26, 0.9]
# sigma8: [0.4, 0.81, 1.2]
@@ -98,7 +100,13 @@ fisher:
step: 1e-2
output: 'fisher.dat'
fisher_bias:
cl_sys: '' # Path to file containing modified data vector with the systematic shift to probe
# If the file is provided it should be a FITS or ASCII file with the columns ell and cl_sys
biased_dv: '' # Path to file containing modified data vector with the systematic shift to probe
# If the file is provided it should be a FITS or ASCII file with the same binning as the
# fiducial data vector and the column dv_sys
bias_params:
Omega_c: 0.27
lens0_bias: 1.3
lens0_delta_z: 0.01
src3_delta_z: 0.005