py21cmfast.wrapper.inputs¶
Input parameter classes.
There are four input parameter/option classes, not all of which are required for any
given function. They are SimulationOptions, CosmoParams, AstroParams
and AstroOptions. Each of them defines a number of variables, and all of these
have default values, to minimize the burden on the user. These defaults are accessed via
the _defaults_ class attribute of each class. The available parameters for each are
listed in the documentation for each class below.
Attributes¶
Exceptions¶
Initialize self. See help(type(self)) for accurate signature. |
Classes¶
Options for the ionization routines which enable/disable certain modules. |
|
Astrophysical parameters. |
|
Cosmological parameters. |
|
Class for storing interpolation tables of cosmological functions (e.g. transfer functions, growth factor). |
|
A class defining a collection of InputStruct instances. |
|
A convenient interface to create a C structure with defaults specified. |
|
Structure containing options which affect the matter field (ICs, perturbedfield, halos). |
|
Structure containing broad simulation options. |
|
Class for setting 1D interpolation table. |
Functions¶
|
Validate that a value is between two values. |
|
Check that the halo mass range is sensible given the parameters, when there are discrete halos in the simulation. |
|
Create an attrs.field that is a choice. |
|
Produce a transformer that converts a string to int. |
|
Validate that a value is one of the choices. |
|
Convert from dex to exponential space. |
|
Define an attrs field with a 'transformer' property. |
|
Compute a sequence of redshifts to evolve over that are log-spaced. |
|
Create an attrs field that must be an InputStruct. |
|
Convert from log to linear space. |
Module Contents¶
- py21cmfast.wrapper.inputs.check_halomass_range(inputs: InputParameters) None[source]¶
Check that the halo mass range is sensible given the parameters, when there are discrete halos in the simulation.
We raise an error if there is a gap in the simulated halo mass range, and a warning if the largest halo mass is below the maximum integral mass (without discrete halos).
- Parameters:
inputs (InputParameters)
- Return type:
None
- py21cmfast.wrapper.inputs.choice_field(*, validator=None, **kwargs)[source]¶
Create an attrs.field that is a choice.
- py21cmfast.wrapper.inputs.choice_transformer(choice: str, att: attrs.Attribute) int[source]¶
Produce a transformer that converts a string to int.
The function must be passed a list of string choices. The resulting int is the index of the choice made.
- Parameters:
choice (str)
att (attrs.Attribute)
- Return type:
int
- py21cmfast.wrapper.inputs.choice_validator(inst, att: attrs.Attribute, val)[source]¶
Validate that a value is one of the choices.
- Parameters:
att (attrs.Attribute)
- py21cmfast.wrapper.inputs.dex2exp_transformer(x, att: attrs.Attribute)[source]¶
Convert from dex to exponential space.
Notes
The reason why we convert our sigma parameters (the width of the lognormal distributions) from base-10 to base-e is because the C code works with lognormal distributions in base-e, for the following reasons: 1. If HALO_SCALING_RELATIONS_MEDIAN = False, the mu parameter of the distribution has to be adjusted by a factor of the form exp(-sigma^2 /2), if the distribution and sigma are in base-e, or by a factor of the form 10^{-ln(10)*sigma^2 /2} if the distribution and sigma are in base-10. Using base-e in the C code saves us from multiplying by ln(10). 2. In the case of stellar mass (stellar fraction), there is a multiplicative term of the form exp(-M_turn/M). Numerically, it is more efficient to combine the arguments of this exponent with the normally distributed random variable (to make the distribution log-normal), which is what the C code does. Working with base-10 in the C could would require having an expression like 10^[-M_turn/M /ln(10)], if we wish to combine the arguments in the power-law. Since the C code works with base-e, it saves the need to divide by ln(10).
While the multiplication/division by ln(10) is not a major overhead for one halo, when the box contains billions of halos that are evolved through various redshift snapshots, the work with base-e in the C code saves us from executing billions of unnecessary multiplications/divisions.
- Parameters:
att (attrs.Attribute)
- py21cmfast.wrapper.inputs.field(*, transformer=None, **kw)[source]¶
Define an attrs field with a ‘transformer’ property.
The transformer, if given, should be a function of a single variable, which will be the attribute’s value. It will be used to transform the value before usage in C-code (e.g. by transformin from log to linear space).
- py21cmfast.wrapper.inputs.get_logspaced_redshifts(min_redshift: float, z_step_factor: float, max_redshift: float) tuple[float, ...][source]¶
Compute a sequence of redshifts to evolve over that are log-spaced.
- Parameters:
min_redshift (float)
z_step_factor (float)
max_redshift (float)
- Return type:
tuple[float, …]
- py21cmfast.wrapper.inputs.input_param_field(kls: InputStruct)[source]¶
Create an attrs field that must be an InputStruct.
- Parameters:
kls (InputStruct subclass) – The parameter structure which should be returned as an attrs field
- Parameters:
kls (InputStruct)