示例#1
0
    def __init__(
            self,
            catalogue_file='limlam_mocker/catalogues/default_catalogue.npz',
            map_output_file='limlam_output.npz',
            scatter_seed=None,
            **obs_kwargs):

        # Initialize LineObs and LineMoedl
        LineObs.__init__(self, **obs_kwargs)

        # Simulation parameters
        self._sim_params = locals()
        self._sim_params.pop('self')
        self._sim_params.pop('obs_kwargs')
        self._default_sim_params = get_default_params(LimLam.__init__)

        for key in self._sim_params:
            setattr(self, key, self._sim_params[key])

        # Sims currently only available for ML models
        '''
        if self.model_type!='ML':
            raise ValueError('Limlam sims only available for ML models')
        '''
        # Combine sim_params with obs_params
        self._input_params.update(self._sim_params)
        self._default_params.update(self._default_sim_params)
示例#2
0
文件: lim.py 项目: yuntingcheng/lim
    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)
示例#3
0
    def __init__(
        self,
        Tsys_NEFD=40 * u.K,
        Nfeeds=19,
        beam_FWHM=4.1 * u.arcmin,
        Delta_nu=8 * u.GHz,
        dnu=15.6 * u.MHz,
        tobs=6000 * u.hr,
        Omega_field=2.25 * u.deg**2,
        Nfield=1,
        line_width=0. * u.km / u.s,
        Tmin_VID=1.0e-2 * u.uK,
        Tmax_VID=1000. * u.uK,
        nT=10**5,
        do_fast_VID=True,
        sigma_G=1.6,
        Ngal_max=100,
        use_sim_PofN=False,
        Nbin_hist=101,
        subtract_VID_mean=False,
        linear_VID_bin=False,
        nz_Cl=100,  # Number of redshift bins for Cl integrals
        nk_Cl=2000,  # Number of k bins for Cl integrals
        lmin=2,
        lmax=10**4,
        nl=100,
        linear_l=False,
        do_limber=False,  # Solve Cl in limber approx.
        processes=4,  # Number of processes for Cl multithreading
        # No parallelism if processes=1
        **line_kwargs):

        # Initiate LineModel() parameters
        #super(LineObs, self).__init__(**line_kwargs) # PROBLEM WITH autoreload
        LineModel.__init__(self, **line_kwargs)

        self._obs_params = locals()
        self._obs_params.pop('self')
        self._obs_params.pop('line_kwargs')
        self._default_obs_params = get_default_params(LineObs.__init__)
        check_params(self._obs_params, self._default_obs_params)

        # Set instrument parameters
        for key in self._obs_params:
            setattr(self, key, self._obs_params[key])
            self._current_params[key] = self._obs_params[key]

        # Combine lim_params with obs_params
        self._input_params.update(self._obs_params)
        self._default_params.update(self._default_obs_params)
示例#4
0
def remove_invalid_params(params, doObs, doSim):
    '''
    Function to remove excess inputs from dictionary.  For example, LineModel
    does not use the inputs of LineObs, such as beam_FWHM, so we want to
    delete them from params before calling LineModel.
    '''

    y = params.copy()  # Can't change size of dictionary in for loop, also
    # removing parameters from params directly messes with
    # autoreload

    x = get_default_params(LineModel.__init__)
    if doObs:
        x1 = get_default_params(LineObs.__init__)
        x.update(x1)
    if doSim:
        x2 = get_default_params(LimLam.__init__)
        x.update(x2)

    for key in params:
        if key not in x:
            y.pop(key)

    return y
示例#5
0
 def __init__(self, Tsys=40*u.K, Nfeeds=19, beam_FWHM=4.1*u.arcmin, 
                 Delta_nu=8*u.GHz, dnu=15.6*u.MHz, tobs=6000*u.hr, 
                 Omega_field=2.25*u.deg**2, Nfield=1,**line_kwargs):
                 
     # Initiate LineModel() parameters
     #super(LineObs, self).__init__(**line_kwargs) # PROBLEM WITH autoreload
     LineModel.__init__(self,**line_kwargs)
     
     self._obs_params = locals()
     self._obs_params.pop('self')
     self._obs_params.pop('line_kwargs')
     self._default_obs_params = get_default_params(LineObs.__init__)
     check_params(self._obs_params,self._default_obs_params)
     
     # Set instrument parameters
     for key in self._obs_params:
         setattr(self,key,self._obs_params[key])
     
     # Combine lim_params with obs_params
     self._input_params.update(self._obs_params)
     self._default_params.update(self._default_obs_params)
示例#6
0
 def __init__(self,Tmin=1.0e-2*u.uK, Tmax=1000.*u.uK, nT=10**5,
              do_fast=True, sigma_G=1.6, Nmax=100, Nbin_hist=101,
              subtract_mean=False,linear_bin=False,**obs_kwargs):
              
     LineObs.__init__(self,**obs_kwargs)
     
     # Get input parameters and check that they are valid
     self._vid_params = locals()
     self._vid_params.pop('self')
     self._vid_params.pop('obs_kwargs')
     self._default_vid_params = get_default_params(VID.__init__)
     check_params(self._vid_params,self._default_vid_params)
     
     if self.model_type!='LF':
         raise ValueError('VID computations only available for LF models')
     
     # Set VID parameters
     for key in self._vid_params:
         setattr(self,key,self._vid_params[key])
         
     # Combine vid_params with obs_params
     self._input_params.update(self._vid_params)
     self._default_params.update(self._default_vid_params)
示例#7
0
    def __init__(self,
                 Tsys_NEFD=40 * u.K,
                 Nfeeds=19,
                 beam_FWHM=4.1 * u.arcmin,
                 Delta_nu=8 * u.GHz,
                 dnu=15.6 * u.MHz,
                 tobs=6000 * u.hr,
                 Omega_field=2.25 * u.deg**2,
                 Nfield=1,
                 Tmin_VID=1.0e-2 * u.uK,
                 Tmax_VID=1000. * u.uK,
                 nT=10**5,
                 do_fast_VID=True,
                 sigma_G=1.6,
                 Ngal_max=100,
                 Nbin_hist=101,
                 subtract_VID_mean=False,
                 linear_VID_bin=False,
                 **line_kwargs):

        # Initiate LineModel() parameters
        #super(LineObs, self).__init__(**line_kwargs) # PROBLEM WITH autoreload
        LineModel.__init__(self, **line_kwargs)

        self._obs_params = locals()
        self._obs_params.pop('self')
        self._obs_params.pop('line_kwargs')
        self._default_obs_params = get_default_params(LineObs.__init__)
        check_params(self._obs_params, self._default_obs_params)

        # Set instrument parameters
        for key in self._obs_params:
            setattr(self, key, self._obs_params[key])

        # Combine lim_params with obs_params
        self._input_params.update(self._obs_params)
        self._default_params.update(self._default_obs_params)
示例#8
0
    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