From 96a55bc488e4f79df8dae099d16a2317c5584ee3 Mon Sep 17 00:00:00 2001 From: Humna Awan Date: Mon, 29 Jan 2024 22:22:55 -0500 Subject: [PATCH 1/5] bug fix. --- deepcmbsim/camb_power_spectrum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepcmbsim/camb_power_spectrum.py b/deepcmbsim/camb_power_spectrum.py index ca08ee2..1210c7a 100644 --- a/deepcmbsim/camb_power_spectrum.py +++ b/deepcmbsim/camb_power_spectrum.py @@ -105,7 +105,7 @@ def get_cls(self, save_to_dict=None, user_params=True): cls_needed = self.UserParams['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 From b34bc89fc6c29db7dff11363de7d33a478bbeaf9 Mon Sep 17 00:00:00 2001 From: Humna Awan Date: Mon, 29 Jan 2024 22:23:52 -0500 Subject: [PATCH 2/5] added a check to ensure EB isn't requested (since it cant be outputted). --- deepcmbsim/camb_power_spectrum.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deepcmbsim/camb_power_spectrum.py b/deepcmbsim/camb_power_spectrum.py index 1210c7a..26a97b3 100644 --- a/deepcmbsim/camb_power_spectrum.py +++ b/deepcmbsim/camb_power_spectrum.py @@ -103,6 +103,8 @@ def get_cls(self, save_to_dict=None, user_params=True): cls_needed = ['clTT', 'clEE', 'clBB', 'clTE', 'clPP', 'clPT', 'clPE'] else: cls_needed = self.UserParams['cls_to_output'] + if 'EB' 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 ('clBB' in cls_needed) or ('clTE' in cls_needed): From 57668b75d717ec8c7e23fbcd08da1008db9ae985 Mon Sep 17 00:00:00 2001 From: Humna Awan Date: Mon, 29 Jan 2024 22:26:32 -0500 Subject: [PATCH 3/5] minor update: ell-array now an array. --- deepcmbsim/camb_power_spectrum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepcmbsim/camb_power_spectrum.py b/deepcmbsim/camb_power_spectrum.py index 26a97b3..f3a8f5e 100644 --- a/deepcmbsim/camb_power_spectrum.py +++ b/deepcmbsim/camb_power_spectrum.py @@ -98,7 +98,7 @@ 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: From 4e471837706db4175bed973c500acc86cd06b8b4 Mon Sep 17 00:00:00 2001 From: Humna Awan Date: Mon, 29 Jan 2024 22:28:34 -0500 Subject: [PATCH 4/5] added functionality to implement lmin-clipping via a user option. --- deepcmbsim/camb_power_spectrum.py | 8 ++++++++ deepcmbsim/settings/user_config.yaml | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/deepcmbsim/camb_power_spectrum.py b/deepcmbsim/camb_power_spectrum.py index f3a8f5e..892e565 100644 --- a/deepcmbsim/camb_power_spectrum.py +++ b/deepcmbsim/camb_power_spectrum.py @@ -146,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'), diff --git a/deepcmbsim/settings/user_config.yaml b/deepcmbsim/settings/user_config.yaml index 9fe9ecc..9c345ef 100644 --- a/deepcmbsim/settings/user_config.yaml +++ b/deepcmbsim/settings/user_config.yaml @@ -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' \ No newline at end of file From a5b86037cb935d77f72ef774fb35ebe977f706d8 Mon Sep 17 00:00:00 2001 From: Humna Awan Date: Mon, 29 Jan 2024 23:22:49 -0500 Subject: [PATCH 5/5] bug fix in the check on clEB. --- deepcmbsim/camb_power_spectrum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deepcmbsim/camb_power_spectrum.py b/deepcmbsim/camb_power_spectrum.py index 892e565..7cef701 100644 --- a/deepcmbsim/camb_power_spectrum.py +++ b/deepcmbsim/camb_power_spectrum.py @@ -103,7 +103,7 @@ def get_cls(self, save_to_dict=None, user_params=True): cls_needed = ['clTT', 'clEE', 'clBB', 'clTE', 'clPP', 'clPT', 'clPE'] else: cls_needed = self.UserParams['cls_to_output'] - if 'EB' in cls_needed: + 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