diff --git a/conda-env.yml b/conda-env.yml index f6508df..3a6fad0 100644 --- a/conda-env.yml +++ b/conda-env.yml @@ -1,6 +1,6 @@ # draft conda environment file for simcmb -name: deepskies-simcmb +name: simcmb dependencies: - python=3.9 diff --git a/deepcmbsim/camb_power_spectrum.py b/deepcmbsim/camb_power_spectrum.py index ca08ee2..7cef701 100644 --- a/deepcmbsim/camb_power_spectrum.py +++ b/deepcmbsim/camb_power_spectrum.py @@ -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 @@ -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'), 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