def __init__( self, cosmo_model='Planck15', model_type='LF', model_name='SchCut', model_par={ 'phistar': 8.7e-11 * u.Lsun**-1 * u.Mpc**-3, 'Lstar': 2.1e6 * u.Lsun, 'alpha': -1.87, 'Lmin': 500 * u.Lsun }, nu=115 * u.GHz, nuObs=30 * u.GHz, Mmin=1e9 * u.Msun, Mmax=1e15 * u.Msun, nM=5000, hmf_model='Tinker08', Lmin=100 * u.Lsun, Lmax=1e8 * u.Lsun, nL=5000, kmin=1e-2 * u.Mpc**-1, kmax=10. * u.Mpc**-1, nk=100, sigma_scatter=0., fduty=1., do_onehalo=False, do_Jysr=False): # Get list of input values to check type and units self._lim_params = locals() self._lim_params.pop('self') # Get list of input names and default values self._default_lim_params = get_default_params(LineModel.__init__) # Check that input values have the correct type and units check_params(self._lim_params, self._default_lim_params) # Set all given parameters for key in self._lim_params: setattr(self, key, self._lim_params[key]) # Create overall lists of parameters (Only used if using one of # lim's subclasses self._input_params = {} # Don't want .update to change _lim_params self._default_params = {} self._input_params.update(self._lim_params) self._default_params.update(self._default_lim_params) # Create list of cached properties self._update_list = [] # Check if model_name is valid check_model(self.model_type, self.model_name)
def update(self, **new_params): # Check if params dict contains valid parameters check_params(new_params, self._default_params) # If model_type or model_name is updated, check if model_name is valid if ('model_type' in new_params) and ('model_name' in new_params): check_model(new_params['model_type'], new_params['model_name']) elif 'model_type' in new_params: check_model(new_params['model_type'], self.model_name) elif 'model_name' in new_params: check_model(self.model_type, new_params['model_name']) # Clear cached properties so they can be updated for attribute in self._update_list: # Use built-in hmf updater to change h if attribute != 'h': delattr(self, attribute) self._update_list = [] # Set new parameter values for key in new_params: setattr(self, key, new_params[key]) self._current_params[key] = new_params[key] # Update hmf if cosmological model has changed if 'cosmo_model' in new_params: self.h.update(cosmo_model=new_params['cosmo_model']) if 'hmf_model' in new_params: self.h.update(hmf_model=new_params['hmf_model']) if 'nuObs' in new_params: self.h.update(z=self.z) if 'nu' in new_params: self.h.update(z=self.z)
def __init__( self, cosmo_input=dict(f_NL=0, H0=67.0, cosmomc_theta=None, ombh2=0.022, omch2=0.12, omk=0.0, neutrino_hierarchy='degenerate', num_massive_neutrinos=1, mnu=0.06, nnu=3.046, YHe=None, meffsterile=0.0, standard_neutrino_neff=3.046, TCMB=2.7255, tau=None, deltazrei=None, bbn_predictor=None, theta_H0_range=[10, 100], w=-1.0, wa=0., cs2=1.0, dark_energy_model='ppf', As=2e-09, ns=0.96, nrun=0, nrunrun=0.0, r=0.0, nt=None, ntrun=0.0, pivot_scalar=0.05, pivot_tensor=0.05, parameterization=2, halofit_version='mead'), model_type='LF', model_name='SchCut', model_par={ 'phistar': 9.6e-11 * u.Lsun**-1 * u.Mpc**-3, 'Lstar': 2.1e6 * u.Lsun, 'alpha': -1.87, 'Lmin': 5000 * u.Lsun }, hmf_model='ST', bias_model='ST99', bias_par={}, #Otherwise, write a dict with the corresponding values nu=115 * u.GHz, nuObs=30 * u.GHz, Mmin=1e9 * u.Msun, Mmax=1e15 * u.Msun, nM=5000, Lmin=100 * u.Lsun, Lmax=1e8 * u.Lsun, nL=5000, kmin=1e-2 * u.Mpc**-1, kmax=10. * u.Mpc**-1, nk=100, k_kind='log', sigma_scatter=0., fduty=1., do_onehalo=False, do_Jysr=False, do_RSD=True, sigma_NL=7 * u.Mpc, nmu=1000, nonlinear_pm=False, FoG_damp='Lorentzian', smooth=False): # Get list of input values to check type and units self._lim_params = locals() self._lim_params.pop('self') # Get list of input names and default values self._default_lim_params = get_default_params(LineModel.__init__) # Check that input values have the correct type and units check_params(self._lim_params, self._default_lim_params) # Set all given parameters for key in self._lim_params: setattr(self, key, self._lim_params[key]) # Create overall lists of parameters (Only used if using one of # lim's subclasses self._input_params = {} # Don't want .update to change _lim_params self._default_params = {} self._input_params.update(self._lim_params) self._default_params.update(self._default_lim_params) # Create list of cached properties self._update_list = [] # Check if model_name is valid check_model(self.model_type, self.model_name) check_bias_model(self.bias_model) #Set cosmology and call camb self.cosmo_input = self._default_params['cosmo_input'] for key in cosmo_input: self.cosmo_input[key] = cosmo_input[key] self.camb_pars = camb.set_params( H0=self.cosmo_input['H0'], cosmomc_theta=self.cosmo_input['cosmomc_theta'], ombh2=self.cosmo_input['ombh2'], omch2=self.cosmo_input['omch2'], omk=self.cosmo_input['omk'], neutrino_hierarchy=self.cosmo_input['neutrino_hierarchy'], num_massive_neutrinos=self.cosmo_input['num_massive_neutrinos'], mnu=self.cosmo_input['mnu'], nnu=self.cosmo_input['nnu'], YHe=self.cosmo_input['YHe'], meffsterile=self.cosmo_input['meffsterile'], standard_neutrino_neff=self.cosmo_input['standard_neutrino_neff'], TCMB=self.cosmo_input['TCMB'], tau=self.cosmo_input['tau'], deltazrei=self.cosmo_input['deltazrei'], bbn_predictor=self.cosmo_input['bbn_predictor'], theta_H0_range=self.cosmo_input['theta_H0_range'], w=self.cosmo_input['w'], cs2=self.cosmo_input['cs2'], dark_energy_model=self.cosmo_input['dark_energy_model'], As=self.cosmo_input['As'], ns=self.cosmo_input['ns'], nrun=self.cosmo_input['nrun'], nrunrun=self.cosmo_input['nrunrun'], r=self.cosmo_input['r'], nt=self.cosmo_input['nt'], ntrun=self.cosmo_input['ntrun'], pivot_scalar=self.cosmo_input['pivot_scalar'], pivot_tensor=self.cosmo_input['pivot_tensor'], parameterization=self.cosmo_input['parameterization'], halofit_version=self.cosmo_input['halofit_version']) self.camb_pars.WantTransfer = True
def update(self, **new_params): # Check if params dict contains valid parameters #check_params(new_params,self._default_params) # If model_type or model_name is updated, check if model_name is valid if ('model_type' in new_params) and ('model_name' in new_params): check_model(new_params['model_type'], new_params['model_name']) elif 'model_type' in new_params: check_model(new_params['model_type'], self.model_name) elif 'model_name' in new_params: check_model(self.model_type, new_params['model_name']) # Clear cached properties so they can be updated for attribute in self._update_list: # Use built-in hmf updater to change h if attribute != 'cosmo_input': delattr(self, attribute) self._update_list = [] # Set new parameter values for key in new_params: if key != 'cosmo_input': setattr(self, key, new_params[key]) if 'cosmo_input' in new_params: temp = new_params['cosmo_input'] for key in temp: self.cosmo_input[key] = temp[key] self.camb_pars = camb.set_params( H0=self.cosmo_input['H0'], cosmomc_theta=self.cosmo_input['cosmomc_theta'], ombh2=self.cosmo_input['ombh2'], omch2=self.cosmo_input['omch2'], omk=self.cosmo_input['omk'], neutrino_hierarchy=self.cosmo_input['neutrino_hierarchy'], num_massive_neutrinos=self. cosmo_input['num_massive_neutrinos'], mnu=self.cosmo_input['mnu'], nnu=self.cosmo_input['nnu'], YHe=self.cosmo_input['YHe'], meffsterile=self.cosmo_input['meffsterile'], standard_neutrino_neff=self. cosmo_input['standard_neutrino_neff'], TCMB=self.cosmo_input['TCMB'], tau=self.cosmo_input['tau'], deltazrei=self.cosmo_input['deltazrei'], bbn_predictor=self.cosmo_input['bbn_predictor'], theta_H0_range=self.cosmo_input['theta_H0_range'], w=self.cosmo_input['w'], wa=self.cosmo_input['wa'], cs2=self.cosmo_input['cs2'], dark_energy_model=self.cosmo_input['dark_energy_model'], As=self.cosmo_input['As'], ns=self.cosmo_input['ns'], nrun=self.cosmo_input['nrun'], nrunrun=self.cosmo_input['nrunrun'], r=self.cosmo_input['r'], nt=self.cosmo_input['nt'], ntrun=self.cosmo_input['ntrun'], pivot_scalar=self.cosmo_input['pivot_scalar'], pivot_tensor=self.cosmo_input['pivot_tensor'], parameterization=self.cosmo_input['parameterization'], halofit_version=self.cosmo_input['halofit_version'])