Configuring the Theory

Even if the user chooses to use the default theory parameters returned by GalaxySpectrum.default_params(), there are several areas where the user should customize the parameters for the specific data set being fit. We will described these customizations in this section.

Changing the Parametrization

The recommended way to make changes to the model parametrization is by adjusting the parameters in the default pyRSD.rsdfit.theory.parameters.ParameterSet object. The user should get the default parameters from the default_params() function and then make the desired changes, before writing the parameters to a file.

For example, to fix the satellite fraction and only use 12 free parameters in the fitting procedure, one can simply do

In [1]: from pyRSD.rsd import GalaxySpectrum

In [2]: model = GalaxySpectrum()

# default params
In [3]: params = model.default_params()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-20168f551e3a> in <module>()
----> 1 params = model.default_params()

~/checkouts/readthedocs.org/user_builds/pyrsd/conda/latest/lib/python3.6/site-packages/pyRSD/rsd/power/gal/power_gal.py in default_params(self)
    128         """
    129         from pyRSD.rsdfit.theory import GalaxyPowerParameters
--> 130         return GalaxyPowerParameters.from_defaults(model=self)
    131 
    132     #---------------------------------------------------------------------------

~/checkouts/readthedocs.org/user_builds/pyrsd/conda/latest/lib/python3.6/site-packages/pyRSD/rsdfit/theory/base.py in from_defaults(cls, model, extra_params)
    155         """
    156         # initialize an empty class
--> 157         params = cls()
    158 
    159         # add extra parameters

~/checkouts/readthedocs.org/user_builds/pyrsd/conda/latest/lib/python3.6/site-packages/pyRSD/rsdfit/parameters/parameterset.py in __init__(self, *args, **kwargs)
     35     def __init__(self, *args, **kwargs):
     36 
---> 37         kwargs['asteval'] = lmfit.asteval.Interpreter(symtable=SmartSymTable(self))
     38         super(ParameterSet, self).__init__(*args, **kwargs)
     39         self._prepared = False

AttributeError: module 'lmfit' has no attribute 'asteval'

# fix the satellite fraction
In [4]: params['fs'].vary = False
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-4-7044e8003dc4> in <module>()
----> 1 params['fs'].vary = False

NameError: name 'params' is not defined

# write new configuration to a file
In [5]: params.to_file('params.dat', mode='a')
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-5-a71e8f6ee5f2> in <module>()
----> 1 params.to_file('params.dat', mode='a')

NameError: name 'params' is not defined

The Sample Number Density

The model requires the number density of the sample to properly account for 1-halo terms. This number density is assumed to be constant and in the case of a number density that varies with redshift, the value can be thought of an average number density.

Note

Typically, the number density value used is the inverse of the sample shot noise.

The value of the nbar parameter should be updated by the user, as

# get the default params
In [6]: params = model.default_params()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-20168f551e3a> in <module>()
----> 1 params = model.default_params()

~/checkouts/readthedocs.org/user_builds/pyrsd/conda/latest/lib/python3.6/site-packages/pyRSD/rsd/power/gal/power_gal.py in default_params(self)
    128         """
    129         from pyRSD.rsdfit.theory import GalaxyPowerParameters
--> 130         return GalaxyPowerParameters.from_defaults(model=self)
    131 
    132     #---------------------------------------------------------------------------

~/checkouts/readthedocs.org/user_builds/pyrsd/conda/latest/lib/python3.6/site-packages/pyRSD/rsdfit/theory/base.py in from_defaults(cls, model, extra_params)
    155         """
    156         # initialize an empty class
--> 157         params = cls()
    158 
    159         # add extra parameters

~/checkouts/readthedocs.org/user_builds/pyrsd/conda/latest/lib/python3.6/site-packages/pyRSD/rsdfit/parameters/parameterset.py in __init__(self, *args, **kwargs)
     35     def __init__(self, *args, **kwargs):
     36 
---> 37         kwargs['asteval'] = lmfit.asteval.Interpreter(symtable=SmartSymTable(self))
     38         super(ParameterSet, self).__init__(*args, **kwargs)
     39         self._prepared = False

AttributeError: module 'lmfit' has no attribute 'asteval'

# this is the default nbar value
In [7]: print(params['nbar'])
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-7-f96c9626798f> in <module>()
----> 1 print(params['nbar'])

NameError: name 'params' is not defined

# change to the right value
In [8]: params['nbar'].value = 4e-5 # in units of (Mpc/h)^{-3}
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-8-4ebd75800de5> in <module>()
----> 1 params['nbar'].value = 4e-5 # in units of (Mpc/h)^{-3}

NameError: name 'params' is not defined

Configuring the GalaxySpectrum Model

The GalaxySpectrum model has several configuration parameters, which can be passed to __init__() function. Most of these parameters have sensible default values that should not be changed by the user. However, there are a few that should be changed based on the data set being fit. The most important are the sample redshift and the cosmological parameters.

The redshift of the sample is taken to be constant. For samples that have a number density varying with redshift, the redshift should be set to the effective redshift of the sample. In the parameter file passed to rsdfit the redshift can be set as:

model.z = 0.55

The cosmological parameters can also be specified by the user in the parameter file – they set the shape of the linear power spectrum which is the input to the GalaxySpectrum model. However, if an already initialized model is being passed to the rsdfit command via the -m flag, then the user doesn’t necessarily need to specify the cosmology again.

The cosmological parameters can be specified in a number of ways:

  1. the name of a file

    The cosmological parameters can be read from a parameter file. See the pyRSD/data/params directory for example parameter files.

  2. the name of a builtin cosmology

    The name of a builtin cosmology, such as Planck15 or WMAP9

  3. a dictionary of parameters

    A dictionary of key/value pairs, such as Ob0, Om0, etc, which will be passed to the pyRSD.rsd.cosmology.Cosmology.__init__ function.

The cosmology parameters can be specified in the parameter file by setting the model.params parameter. For example, to use the WMAP9 parameter set, simply specify the following in the parameter file:

model.params = "WMAP9"

Additionally, there are other model configuraton parameters that can be set in the parameter file, as long as they are prefixed with model.. The config attribute of the GalaxySpectrum object gives these values

In [9]: from pyRSD.rsd import GalaxySpectrum

In [10]: model = GalaxySpectrum()

In [11]: for k in sorted(model.config):
   ....:     print("%s = %s" %(k, str(model.config[k])))
   ....: 
Nk = 200
Pdv_model_type = jennings
correct_mu2 = False
correct_mu4 = False
fog_model = modified_lorentzian
include_2loop = False
interpolate = True
k0_low = 0.005
kmax = 0.5
kmin = 0.001
linear_power_file = None
max_mu = 4
params = {'H0': 67.74, 'Om0': 0.3075, 'sigma8': 0.8159, 'n_s': 0.9667, 'flat': True, 'w0': -1.0, 'name': 'Planck15', 'Ob0': 0.0486, 'Tcmb0': 2.7255, 'Neff': 3.046, 'm_nu': array([0.  , 0.  , 0.06])}
transfer_fit = CLASS
use_P00_model = True
use_P01_model = True
use_P11_model = True
use_Pdv_model = True
use_Phm_model = True
use_Pvv_model = True
use_mean_bias = False
use_so_correction = False
use_tidal_bias = False
use_vlah_biasing = True
vel_disp_from_sims = False
z = 0.0