py21cmfast.CosmoParams¶
- class py21cmfast.CosmoParams¶
Bases:
InputStructCosmological parameters (with defaults) which translates to a C struct.
To see default values for each parameter, use
CosmoParams._defaults_. All parameters passed in the constructor are also saved as instance attributes which should be considered read-only. This is true of all input-parameter classes.Default parameters are based on Plank18, https://arxiv.org/pdf/1807.06209.pdf, Table 2, last column. [TT,TE,EE+lowE+lensing+BAO]
- Parameters:
SIGMA_8 (float, optional) – RMS mass variance (power spectrum normalisation).
hlittle (float, optional) – The hubble parameter, H_0/100.
OMm (float, optional) – Omega matter.
OMb (float, optional) – Omega baryon, the baryon component.
POWER_INDEX (float, optional) – Spectral index of the power spectrum.
A_s (float, optional) – Amplitude of primordial curvature power spectrum, at k_pivot = 0.05 Mpc^-1.
- classmethod __init_subclass__()¶
Store each subclass for easy access.
- Return type:
None
- __str__()¶
Human-readable string representation of the object.
- Return type:
str
- asdict()¶
Return a dict representation of the instance.
Examples
This dict is such that doing the following should work, i.e. it can be used exactly to construct a new instance of the same object:
>>> inp = InputStruct(**params) >>> newinp =InputStruct(**inp.asdict()) >>> inp == newinp
- Return type:
dict
- clone(**kwargs)¶
Make a fresh copy of the instance with arbitrary parameters updated.
- classmethod from_astropy(cosmo, **kwargs)¶
Create a CosmoParams object from an astropy cosmology object.
Pass SIGMA_8 and POWER_INDEX as kwargs if you want to override the default values.
- Parameters:
cosmo (astropy.cosmology.FLRW)
- classmethod from_subdict(dct, safe=True)¶
Construct an instance of a parameter structure from a dictionary.
- classmethod new(x=None, **kwargs)¶
Create a new instance of the struct.
- Parameters:
x (dict | InputStruct | None) – Initial values for the struct. If x is a dictionary, it should map field names to their corresponding values. If x is an instance of this class, its attributes will be used as initial values. If x is None, the struct will be initialised with default values.
- Other Parameters:
All other parameters should be passed as if directly to the class constructor
(i.e. as parameter names).
- Parameters:
x (dict | Self | None)
Examples
>>> up = SimulationOptions({'HII_DIM': 250}) >>> up.HII_DIM 250 >>> up = SimulationOptions(up) >>> up.HII_DIM 250 >>> up = SimulationOptions() >>> up.HII_DIM 200 >>> up = SimulationOptions(HII_DIM=256) >>> up.HII_DIM 256
- property A_s: float¶
Amplitude of primordial curvature power spectrum, at k_pivot = 0.05 Mpc^-1.
If not given explicitly, it is auto-calculated via sigma_8 and the other cosmological parameters.
- Return type:
float
- OMb: float¶
- OMk: float¶
- property OMl¶
Omega lambda, dark energy density.
- OMm: float¶
- OMn: float¶
- OMr: float¶
- OMtot: float¶
- POWER_INDEX: float¶
- property SIGMA_8: float¶
RMS mass variance (power spectrum normalisation).
If not given explicitly, it is auto-calculated via A_s and the other cosmological parameters.
- Return type:
float
- Y_He: float¶
- property cdict: dict¶
A python dictionary containing the properties of the wrapped C-struct.
The memory pointed to by this dictionary is not owned by the wrapped C-struct, but is rather just a python dict. However, in contrast to
asdict(), this method transforms the properties to what they should be in C (e.g. linear space vs. log-space) before putting them into the dict.This dict also contains only the properties of the wrapped C-struct, rather than all properties of the
InputStructinstance (some attributes of the python instance are there only to guide setting of defaults, and don’t appear in the C-struct at all).- Return type:
dict
- property cosmo¶
An astropy cosmology object for this cosmology.
- property cstruct: py21cmfast.wrapper.structs.StructWrapper¶
The object pointing to the memory accessed by C-code for this struct.
- Return type:
- hlittle: float¶
- property struct: py21cmfast.wrapper.structs.StructWrapper¶
The python-wrapped struct associated with this input object.
- Return type:
- wl: float¶