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

bug fix, minor check+update, functionality to implement lmin-clipping #89

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 12 additions & 2 deletions deepcmbsim/camb_power_spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ def get_cls(self, save_to_dict=None, user_params=True):
# main calculation: https://camb.readthedocs.io/en/latest/camb.html#camb.get_results
results = camb.get_results(self.CAMBparams)

outdict = { 'l': range(self.max_l_use + 1) }
outdict = { 'l': np.arange(self.max_l_use+1) }
if self.UserParams['cls_to_output'] == 'all':
cls_needed = ['clTT', 'clEE', 'clBB', 'clTE', 'clPP', 'clPT', 'clPE']
else:
cls_needed = self.UserParams['cls_to_output']
if 'clEB' in cls_needed:
raise ValueError('camb does NOT output EB => it cant be in cls_to_output.')

# https://camb.readthedocs.io/en/latest/results.html#camb.results.CAMBdata.get_total_cls
if ('clTT' in cls_needed) or ('clEE' in cls_needed) or ('clEB' in cls_needed) or ('clTE' in cls_needed):
if ('clTT' in cls_needed) or ('clEE' in cls_needed) or ('clBB' in cls_needed) or ('clTE' in cls_needed):
# need to run things to get one/some/all of tt, ee, bb, te
tt, ee, bb, te = results.get_total_cls(raw_cl=self.normalize_cls, CMB_unit=self.TT_units)[:self.max_l_use + 1].T
# add noise
Expand Down Expand Up @@ -144,6 +146,14 @@ def get_cls(self, save_to_dict=None, user_params=True):
else:
raise ValueError('somethings wrong.')

# see if lmin is specified - if so, discard the ells < lmin
if self.UserParams['lmin'] != 0:
ell_inds = np.where(outdict['l'] >= self.UserParams['lmin'])[0]
if bool(self.UserParams["verbose"]):
print(f'## discarding {len(outdict["l"]) - len(ell_inds)} ells given lmin specification.')
for key in outdict.keys():
outdict[key] = outdict[key][ell_inds]

if bool(self.UserParams["verbose"]):
time_end = dt.now()
print('from', dt.strftime(time_start, '%H:%M:%S.%f %P'), 'to', dt.strftime(time_end, '%H:%M:%S.%f %P'),
Expand Down
4 changes: 4 additions & 0 deletions deepcmbsim/settings/user_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ extra_l: 300
max_l_use: 10000 # max_l_use will differ from max_l and max_l_tensor by "extra_l" because
# according to the CAMB documentation errors affect the last "100 or so" multipoles
# ---
# decide on lmin: CAMB will still be called with lmin=0 but
# you may specifiy lmin for the output spectra
lmin: 0
# ---
# decide on what to output; either 'all' or a subset list of
# ['clTT', 'clEE', 'clBB', 'clTE', 'clPP', 'clPT', 'clPE']
cls_to_output: 'all'
Loading